Add gridlines to a output plot in Mathemaitca

Posted by xslittlegrass on Stack Overflow See other posts from Stack Overflow or by xslittlegrass
Published on 2012-11-16T17:18:48Z Indexed on 2012/11/16 23:00 UTC
Read the original article Hit count: 285

Filed under:
|

I'm trying to add gridlines to a output density plot in Mathematica. The plot is generated by a long calculation in Mathematica and when I do the plot I forget to add the Mesh->True options. I don't want to do all the calculation and generate the plot again since it takes a long time. Is that possible to add the gridlines or mesh lines to plot ONLY using the output plot at hand?

For example, If I have a plot p. Is it possible to add the mesh lines ONLY manipulate p?

In a ordinary one dimensional plot, this will work

p1 = Plot[Sin[x], {x, -3, 3}];

Insert[p1, GridLines -> Automatic, -1]

enter image description here

But when I try the density plot, it seems the gridlines is always under the plot, and can be seen only at the image margin area.

p2 = DensityPlot[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PlotRangePadding -> 0.2];
Insert[p2, GridLines -> Automatic, -1]

enter image description here

Updata

The Mesh option on the output plot will not work because Mesh is not a options of a Graphics:

Show[p2,Mesh->True]

will give a message "an unrecoginzed option name(Mesh) was encountered while rendering a Graphics" Thanks.

© Stack Overflow or respective owner

Related posts about plot

Related posts about mathematica