Prev: Select list elements and exchange them
Next: Equals, Less, Greater, etc; Confused by this simple output.
From: Patrick Scheibe on 19 May 2010 20:10 Hi, and setting the DataRange (or searching this forum before asking) doesn't help? data = Table[Sin[x*y], {y, -Pi, Pi, 0.1}, {x, -Pi, Pi, 0.1}]; ap = ArrayPlot[data, DataRange -> {{-1, 1}, {-1, 1}}]; lp = ListLinePlot[Transpose[data][[10]], DataRange -> {-1, 1}, PlotStyle -> {{Thick, Red}}]; Show[ap, lp] Cheers, Patrick Am May 19, 2010 um 1:01 PM schrieb Vadim Zaliva: > I have a strange problem with combining 2 plots: > > ap = ArrayPlot[Transpose[l]] > lp = ListLinePlot[{a, b, c}] > > Each of 'ap' and 'lp' is shown correctly. However combining them via: > > Show[ap,lp] > > always shows just ap. > > Dimensions[Transpose[l]] is {44, 2000} > a,b,c have same dimension {2000} > > I feel like I am missing something obvious here... > > Vadim >
From: Vadim Zaliva on 21 May 2010 06:47 I would like to thank everybody for their answers. The problem is not solved yet. 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: http://yfrog.com/afscreenshot20100519at112p For list line plot, dimensions length all my data vectors is 2000. So I exect X range to be {1,2000} and y range depend on data values. Indeed on the plot I see ticks showing correct values for X, but "Get Coordinates" shows x ranges approx. {-0.1,1}. Screenshot: http://yfrog.com/eiscreenshot20100519at113p I think this is the source of the problem. Show using x range {1,2000}, so all ListLinePlot is probably squeezed into couple of pixels in the beginning. Result of Show: http://yfrog.com/1gscreenshot20100519at113p Show supposed to take range from the first element, but for some reason changing order of plots in show does not make any difference. Sincerely, Vadim
From: Patrick Scheibe on 22 May 2010 00:41 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
From: David Park on 22 May 2010 00:42 It might help if you could post the actual, evaluable, Mathematica code, or maybe the code for a simplified case with simulated data that still exhibits the same problem. Just describing what you did in general terms or posting screen shots will sometimes not capture the source of the problem. David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: Vadim Zaliva [mailto:krokodil(a)gmail.com] I would like to thank everybody for their answers. The problem is not solved yet. 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: http://yfrog.com/afscreenshot20100519at112p For list line plot, dimensions length all my data vectors is 2000. So I exect X range to be {1,2000} and y range depend on data values. Indeed on the plot I see ticks showing correct values for X, but "Get Coordinates" shows x ranges approx. {-0.1,1}. Screenshot: http://yfrog.com/eiscreenshot20100519at113p I think this is the source of the problem. Show using x range {1,2000}, so all ListLinePlot is probably squeezed into couple of pixels in the beginning. Result of Show: http://yfrog.com/1gscreenshot20100519at113p Show supposed to take range from the first element, but for some reason changing order of plots in show does not make any difference. Sincerely, Vadim
From: Vadim Zaliva on 22 May 2010 23:33 On May 21, 2010, at 4:56 , David Park wrote: > It might help if you could post the actual, evaluable, Mathematica code, or > maybe the code for a simplified case with simulated data that still exhibits > the same problem. > > Just describing what you did in general terms or posting screen shots will > sometimes not capture the source of the problem. David, Here is the sample code demonstrating what I am trying to do: nplevels = RandomReal[{1, 255}, {44, 1000}] ap = MatrixPlot[nplevels, FrameTicks -> True] psig = RandomReal[{0, 1}, 1000]; lp = ListLinePlot[{psig}] Show[ap, lp] I am trying to combine a matrix representing 2D image with a plot of some signal related to this image. I think the source of my problem is that while X coordinates match, the ranges of Y coordinates very different. It is 1-255 for image data and 0-1 for the signal. Ideally I would like to have an image plot on top of ListLinePlot. Of course I can combine them via GraphicsColumn, but I want them to be aligned along X coordinates. Thanks! Vadim P.S. I did read and re-read documentation on plot functions an been experimenting with DataRange, PlotRange and other options before seeking kind help from a members of this list :)
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Select list elements and exchange them Next: Equals, Less, Greater, etc; Confused by this simple output. |