[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plotting two sets of contours

ahw199@soton.ac.uk (Ann Webber) writes:

> I am trying to plot two different sets of contours over one image. The
> contour sets are both centered around different points, So I need to
> position them separately. I can overplot one set at the right point
> but when it comes to the second set the position keyword doesnt seem
> to work and the second set are overplotted over the first set.
> Do I need to combine all the data into one file, i.e. work out the two
> plots in relation to each other or can I use some other keyword to
> position the second set?

Ann, I think you are using CONTOUR the wrong way.  The position
keyword is used to position a plot within the viewport, in normalized
or device coordinates, and never in data coordinates.

You say the contour plots are "centered on different points" but that
shouldn't make a difference.  As long as you establish a coordinate
system with your image, then you should be able to overlay contours
using *the coordinates of the contour images*.

The key is to establish a coordinate system with your image.  One way
to do this is with my PLOTIMAGE, or Liam's IMDISP.  Or, you can do it
yourself (somewhat painfully), by loading the image with TV,
overplotting a coordinate system, and then overplotting the contours.

xx = findgen(100)/10   ;; Create x- and y-coordinates from 0 to 10
yy = xx
zz = cos(xx # yy)      ;; Create two data sets based on X and Y
zz2 = (xx#(yy*0+1))^2 + ((xx*0+1)#yy)^2

tv, bytscl(zz,min=-1,max=1,top=200)+1, 100,100  ;; Draw image 

;; Next plot establishes a coordinate system from 0 to 10, from pixels
;;  numbered 100 to 200
plot, [0,10],[0,10], /xstyle, /ystyle, /nodata, /noerase, $
	position=[100,100,200,200], /device

;; Overlay the contour data from the other image
contour, zz2, xx, yy, levels=[0,2,5,10,20,50,80,100,120,150,180,200], /over

The thing that really confused me was that your sample program was
trying to contour a vector, not an image

> CONTOUR,A(7,*),A(0,*),A(1,*),/irregular,levels=[6,8,10,15,18,20,25,30,40,50,60,70,80,90,100,150,200],color=2,C_LABELS=[1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1]
> $
> ,position=[515,495,645,625],/device,/noerase,/overplot

The subarray A(7,*) is a 1-d vector, not an image.  I can't see how
that would work.

Good luck,

Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response