MathGroup Archive 2010

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

Search the Archive

Re: combining ArrayPlot with ListLinePlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109923] [mg109923] Re: combining ArrayPlot with ListLinePlot
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sat, 22 May 2010 23:34:10 -0400 (EDT)
  • References: <ht1ul8$35o$1@smc.vnet.net> <22897006.1274440296212.JavaMail.root@n11> <002a01caf8dc$98d57520$ca805f60$@net> <2870450.1274492022439.JavaMail.root@n11>

Vadim,

The following is a method to obtain the ListLinePlot on top of the
MatrixPlot:

nplevels = RandomReal[{1, 255}, {44, 1000}]; 
psig = RandomReal[{0, 1}, 1000]; 
lp = ListLinePlot[{psig}]; 
ap = MatrixPlot[nplevels,
   AspectRatio -> 1/GoldenRatio,
   FrameTicks -> True,
   DataRange -> {{0, 1000}, {0, 1}}]; 
Show[ap, lp] 

You might want different y scales on the left and right sides for the two
sets of data, which you could get by using the FrameTicks option and writing
custom ticks for one side.

The following is a method to obtain the two plots in a column with the x
axes aligned. The trick here is to use the same ImageMargins option in the
two plots such that the left hand tick values for both plots will both fit
in the allotted space.

nplevels = RandomReal[{1, 255}, {44, 1000}]; 
psig = RandomReal[{0, 1}, 1000]; 
lp = ListLinePlot[{psig},
   Frame -> True,
   ImageMargins -> {{20, 10}, {20, 20}}]; 
ap = MatrixPlot[nplevels,
   AspectRatio -> 1/GoldenRatio,
   FrameTicks -> {{Automatic, None}, {Automatic, None}},
   DataReversed -> False,
   DataRange -> {{0, 1000}, All},
   ImageMargins -> {{20, 10}, {20, 20}}]; 
GraphicsColumn[{ap, lp}] 


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: Vadim Zaliva [mailto:krokodil at gmail.com] 

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 :)




  • Prev by Date: Re: Intersection of sublists on date and making a 2D list from a 3D
  • Next by Date: Re: Intersection of sublists on date and making a 2D list from a 3D
  • Previous by thread: Re: combining ArrayPlot with ListLinePlot
  • Next by thread: Variable MaxStepFraction in NDSolve