Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: combining ArrayPlot with ListLinePlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109904] Re: combining ArrayPlot with ListLinePlot
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Sat, 22 May 2010 00:41:23 -0400 (EDT)

Hi,

> I would like to thank everybody for their answers. The problem is not
> solved yet.

of course this was only a hint which should lead you into the right
direction.

> I tried setting data range and it did not help. The data used in array
> plot has dimensions {44,2000}.
> 
> So I expect x to be in range {1,2000} and y in {1,44}.
> However when I right click on Array Plot and select "Show
> Coordinates" I can see that x is indeed in the right range, but
> y range is something like {-45,82}. A screenshot:

Mathematica makes a lot of stuff to create nice plots. This includes
frames and spaces around plots. So what you see (and get with Show
Coordinates) can be different from the underlying data-range.
But there are options for those settings and a look in the ArrayPlot doc
would have showed you what to try:

nx = 200;
ny = 44;
data1 = Table[
   Re[ArcSec[x + I y]], {y, -Pi, Pi, 2 Pi/(ny - 1.)}, {x, -Pi, Pi, 
    2 Pi/(nx - 1.)}];
ap = ArrayPlot[data, DataRange -> {{0, nx}, {0, ny}}, 
  PlotRangePadding -> None, Frame -> False, ImagePadding -> None, 
  PlotRangeClipping -> True]

This should give you a graphics where the Show Coordinates should be
what you expected. The data ranges from {{0, 200}, {0, 44}}.

Say, I create now a ListLinePlot with exactly 200 points and the values
range from about 2 to 30.

lp = ListLinePlot[10 data[[22]], PlotRange -> {{0, nx}, Automatic}, 
  DataRange -> {0, nx}]

Combining the two graphics

Show[{ap, lp}]

creates an image where the function-graph goes from the left image
border to the right, as expected. Remembering that the image is 44 units
high, the scale of the y-values in the function seem to fit too.

What I don't understand is, why you care about that "Show Coordinates"
doesn't work as expected. Say I have an ArrayPlot with your data range
and I want to draw a line from the left-lower corner to the right-upper
corner, then the function is 44x/2000:

Show[{ArrayPlot[Table[1, {44}, {2000}], 
   DataRange -> {{0, 2000}, {0, 44}}],
  Plot[44 x/2000., {x, 0, 2000}, PlotStyle -> Yellow]
  }]

this is what I wanted. Ok, there is space around the graphics, but the
contents is correct.

Cheers
Patrick



  • Prev by Date: Re: enter specific symbols for ListPlot usage
  • Next by Date: Re: enter specific symbols for ListPlot usage
  • Previous by thread: Re: combining ArrayPlot with ListLinePlot
  • Next by thread: Re: combining ArrayPlot with ListLinePlot