MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: ListDensityPlot[] : frame ticks help !

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27944] RE: [mg27925] ListDensityPlot[] : frame ticks help !
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 24 Mar 2001 15:15:47 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Fabio,

You can use FrameTicks and make up tables for the tick specifications. But
it is generally a lot of work. I have a package at my web site below, called
DrawingTicksAndGrids, which makes it much easier. It is part of the
DrawingPaper packages, but can be used by itself without the other packages.
Here is a sample case, and how you would use the relevant routine,
CustomTicks.

Needs["Graphics`DrawingTicksAndGrids`"]

This generates a sample data array.

array = Table[Sin[x*y^2], {y, 0., Pi, Pi/50}, {x, 0, Pi, Pi/50}];

Notice that ListDensityPlot plots the rows going up the page and the columns
going across the page, and since we want x to go across the page, I reversed
the order of x and y in the Table. (You may want to Transpose your data
table.) This makes your ListDensityPlot, the one you don't like because the
axes are labeled by column and row number and not by the true values.

ListDensityPlot[array, FrameLabel -> {x, y}];

Now, here is a fine point. Notice that the first column corresponds to x =
0, and the proper position for x = 0 should be in the middle of the column,
that is, at the value 1/2 in the plot's coordinates. Similarly the value x =
Pi corresponds to the value 50.5 in the plot's coordinates.

To add your custom tick marks, use CustomTicks.

?CustomTicks
\!\("CustomTicks[inversefunction, tickspecs, options] will generate custom \
tick marks. If the normal axes is given by the variable u, but is to labeled
\
by v = f[u] then the inverse function \!\(f\^\(-1\)\) must be supplied as a
\
pure function. If a linear scale is to be used, tickspecs will take the
form: \
{start, end, inc, subdivisions}. subdivisions of n will provide n-1
unlabeled \
tick marks between each labeled tick mark. If a log scale is to be used, \
tickspecs will take the form {startpower, endpower, vals, subvals} where
vals \
and subvals are the lists of the labeled and unlabeled values in one decade.
\
The labeled ticks will be \!\(10\^power\) vals where power ranges from the \
start to end value. Mathematica will eliminate any ticks which are outside \
the PlotRange.\n\nThe options for CustomTicks are:CTNumberFunction, \
CTTickSpecs, CTTickStyle, CTUnLabTickSpecs, CTUnLabTickStyle. See their
usage \
messages."\)

To obtain the inverse function that gives the plot coordinates u in terms of
the desired coordinates v:

u[v_] := a + b*v;
absol = Solve[{u[0] == 1/2, u[Pi] == 50 + 1/2}, {a, b}][[1]]
u[v] /. absol
{b -> 50/Pi, a -> 1/2}
1/2 + (50*v)/Pi

We use this in the CustomTicks specification. I have put it in as a pure
function.

ListDensityPlot[array, Mesh -> False, FrameLabel -> {x, y},
   FrameTicks ->
    {CustomTicks[1/2 + (50*#1)/Pi & , {0, Pi, Pi/4, 4}],
     CustomTicks[1/2 + (50*#1)/Pi & , {0, Pi, Pi/4, 4}],
     CustomTicks[1/2 + (50*#1)/Pi & , {0, Pi, Pi/4, 4}, CTNumberFunction ->
("" & )],
     CustomTicks[1/2 + (50*#1)/Pi & , {0, Pi, Pi/4, 4}, CTNumberFunction ->
("" & )]},
   PlotLabel -> Sin[x*y^2], ImageSize -> 500];

I have specified the ticks on all four sides of the frame. On the top and
right hand side, I specified that the numbers should be printed as blanks.
This corresponds to normal Mathematica plots where these sides have the same
ticks but no labels.

There is also a similar routine for making custom grids.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



> From: Tasslehof [mailto:fabio at urania.fisica.unige.it]
To: mathgroup at smc.vnet.net
>
> Hi,
>
> I am using ListDensityPlot to plot a 2D array of data from a simulation,
> which are of the form (x,y,f(x,y)). Of course - i read btw them from an
> external file - mathematica doesn't care about (x,y) values but puts on
> frame ticks the "position number" in the array i read in. I am wondering
> _how_ can i put on the frame ticks the original x,y scales. Sorry for the
> - hopefully not too - FAQ, but I don't know how to work out this. Cheers,
>
>
> |~~~~~~|
> |(O>   |\  Fabio Cavaliere (Homebrew apprentice & GLUG member)
> |//\   | | e-mail > fabio at urania.fisica.unige.it
> |V_/_  | | e-mail2 > cavalie5 at server3.fisica.unige.it
> |######|-  GLUG on the Web : http://genova.linux.it
> +------+
>
>



  • Prev by Date: Re: Differential equations error with MathLink/JLink
  • Next by Date: sounds in linux
  • Previous by thread: Re: ListDensityPlot[] : frame ticks help !
  • Next by thread: Q: Print in different colors