I'm using ListDensityPlot to display a 2880 by 200 matrix of real values.
If I set Mesh->True the result is completely dominated by black mesh lines.
Does anyone know an easy way of displaying a subset of mesh lines?
Thanks,
Chris Walden
--
-----------------------------------------------
Dr C.J. Walden [C.J.W...@rl.ac.uk]
Radio Communications Research Unit
CCLRC Rutherford Appleton Laboratory
Chilton, Didcot, OX11 0QX, UK
Tel:+44-(0)1235-445601 Fax:+44-(0)1235-446140
-----------------------------------------------
Here is an example with DensityPlot. We convert the output to Graphics and
then use GridLines to get something equivalent to a subset of mesh lines.
AxesFront -> True is used to get the grid lines to be in front of the
density plot. In order to use AxesFront we have to import it from
FilledPlot. (I always thought that AxesFront should be part of the regular
2D plot options.)
Needs["Graphics`FilledPlot`"]
Show[Graphics[DensityPlot[Sin[x]Sin[y], {x, -Pi, Pi}, {y, -Pi, Pi},
PlotPoints -> 100,
Mesh -> False,
DisplayFunction -> Identity]],
GridLines -> Automatic,
AxesFront -> True,
ImageSize -> 500,
DisplayFunction -> $DisplayFunction];
If you use DrawGraphics from my web site you don't have to convert to
Graphics, turn the display off and on, or explicitly load FilledPlot, but
you have to set the Frame and AspectRatio. You could easily add other
elements to the plot.
Needs["DrawGraphics`DrawingMaster`"]
Draw2D[
{DensityDraw[Sin[x]Sin[y], {x, -Pi, Pi}, {y, -Pi, Pi},
PlotPoints -> 100, Mesh -> False]},
AspectRatio -> Automatic,
Frame -> True,
GridLines -> Automatic,
AxesFront -> True,
ImageSize -> 500];
David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/
data=Table[Sin[x]/Cos[x^2+y^2],
{x,-2,2,0.02},{y,-2,2,0.025}];
ListDensityPlot[data, Mesh->False,
Epilog->{GrayLevel[.25],
Table[Line[{{x,0},{x,201} }], {x,0,160,8}],
Table[Line[{{0,y},{161,y} }], {y,0,201,10}]}];
Bob Hanlon
In article <bdeeu9$dht$1...@smc.vnet.net>, "Walden, CJ (Chris)"
<C.J.W...@rl.ac.uk> wrote:
<< Subject: Mesh in ListDensityPlot
From: "Walden, CJ (Chris)" <C.J.W...@rl.ac.uk>
Date: Thu, 26 Jun 2003 09:38:17 +0000 (UTC)
Hi,
I'm using ListDensityPlot to display a 2880 by 200 matrix of real values.
If I set Mesh->True the result is completely dominated by black mesh lines.
Does anyone know an easy way of displaying a subset of mesh lines?
>><BR><BR>
Chris,
certainly there is the alternative to just overlay a mesh, made up by
yourself from Graphics primitves over your ListDensityPlot (without mesh).
I will show here, an alternative, namely: how to thin out the mesh from the
DensityGraphics:
Let's define some data:
In[1]:= \[Delta]2 = 40/2880 // N;
\[Delta]1 = 20/200 // N;
In[3]:=
data = Table[Sin[x]/Cos[x^2 + y^2],
{x, -10 + \[Delta]1/2, 10 - \[Delta]1/2, \[Delta]1},
{y, -20 + \[Delta]2/2, 20 - \[Delta]2/2, \[Delta]2}];
In[4]:=
gd = ListDensityPlot[data, Mesh -> True, MeshRange -> {{-20, 20}, {-10,
10}},
AspectRatio -> Automatic, ImageSize -> 800, MeshStyle -> {Hue[1/6]}]
Out[4]= \[SkeletonIndicator]DensityGraphics\[SkeletonIndicator]
This density graphics is unusable (all yellow from the mesh).
We convert the DensityGraphics to a Graphics:
In[5]:= g = Graphics[gd]
Out[5]= \[SkeletonIndicator]Graphics\[SkeletonIndicator]
>From that we extract the mesh lines and it's graphics directives:
In[6]:= oldmesh = Extract[g, pos = Position[g, {___, Line[_] ..}]];
In[7]:= directives = DeleteCases[oldmesh, Line[_], {2}]
Out[7]= {{Hue[1/6], AbsoluteThickness[0.25`], Dashing[{}]}}
In[8]:= pos
Out[8]= {{1, 2}}
In[9]:= lines = Cases[oldmesh, Line[_], {2}];
This are the dimensions of the data:
In[10]:= dd = Dimensions[data]
Out[10]= {200, 2880}
In[11]:= FactorInteger[dd]
Out[11]= {{{2, 3}, {5, 2}}, {{2, 6}, {3, 2}, {5, 1}}}
We search for a pleasant factor for thinning out, and choose
In[12]:= s = {20, 80};
In[13]:= ii = Transpose[{{-1, 1}, {-1, 1}*(dd + 1), s}]
Out[13]= {{-1, -201, 20}, {1, 2881, 80}}
In[14]:= pp = ReplacePart[ii, ii, {{1, 1}, {1, 2}}, {{1, 2}, {1, 1}}]
Out[14]= {{-201, -1, 20}, {1, 2881, 80}}
These are the sequence specifications to take out the thinned mesh. Note the
expression dd+1 (there is one meshline more for each dimension).
In[15]:= newlines = Take[lines, #] & /@ pp;
In[16]:= newmesh = Join @@ Join[directives, newlines];
In the Graphics object, we replace the old mesh by the new one:
In[17]:= gnew = ReplacePart[g, newmesh, pos]
Out[17]= \[SkeletonIndicator]Graphics\[SkeletonIndicator]
All that needs, is to display it:
In[18]:= Show[gnew, Background -> Hue[.8, .2, .8]]
By the way: don't think the Ranges for the mesh were false (by a tiny
amount), to the contrary! They are just right here (but often false
otherwise!). Why?
Well, because it is so easy, here the other method:
In[23]:=
gd0 = ListDensityPlot[data, Mesh -> False,
MeshRange -> {{-20, 20}, {-10, 10}}, AspectRatio -> Automatic,
ImageSize -> 800]
In[24]:=
Show[gd0,
Graphics[ {Hue[0], Table[Line[{{-20, i}, {20, i}}], {i, -10, 10, 2}],
Table[Line[{{j, -10}, {j, 10}}], {j, -20, 20, 2}]}]]
(we simply don't care for the raster, if it is small enough)
--
Hartmut Wolf
ListDensityPlot[yourMesh, Mesh->False]
??
or SetOptions[ListDensityPlot, Mesh->False]
????
Regards
Jens
Here is a little example of what I mean:
ListDensityPlot[Table[Sin[i/5], {i, 100}, {j, 100}], Mesh -> False,
Epilog -> {RGBColor[1, 0, 0], Table[{Line[{{0, i}, {100, i}}],
Line[{{i, 0}, {i, 100}}]}, {i, 0, 100, 10}]}];
--
Steve Luttrell
West Malvern, UK
"Walden, CJ (Chris)" <C.J.W...@rl.ac.uk> wrote in message
news:bdeeu9$dht$1...@smc.vnet.net...