Re: TVimage and PlotS [message #40779] |
Thu, 26 August 2004 07:32 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
James writes:
> But I still didn't clearly understand... I want to plot not lines,
> but dots (or circles). And I have an array of data with coordinates (X,Y).
> How it will work in this case ?
Well, neither of the commands you are using will establish
a data coordinate system for you, so I presume the data is
in device coordinates, is that right? Suppose they are (I
can't imagine anything else.) Let's call them "image" coordinates,
since they probably correspond to points on the image.
(The lack of information from you allows the imagination
to run wild here!)
You can convert them to NORMALIZED coordinates like this:
c = Convert_Coord(x, y, /Device, /To_Normal)
xx = c[0,*]
yy = c[1,*]
Now, you have to scale them into the position of the image
in the window.
xxx = Scale_Vector(xx, pos[0], pos[2])
yyy = Scale_Vector(yy, pos[1], pos[3])
Now, you could draw them on your image:
PLOTS, xxx, yyy, /Normal
You will have to grab SCALE_VECTOR:
http://www.dfanning.com/programs/scale_vector.pro
Of course, all this is bogus if your X and Y vectors don't
correspond to my imagination. (Well, uh, good chance there.)
You could tell us more about them. :-)
> I tried to apply your advise but I didn't get a line across the window...
Well, uh, somebody wrote this:
PLOTS, [pos[0], pos[1]], [pos[1], pos[3]], /Normal
And, of course, they meant this:
PLOTS, [pos[0], pos[2]], [pos[1], pos[3]], /Normal
Sorry. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: TVimage and PlotS [message #40780 is a reply to message #40779] |
Thu, 26 August 2004 07:03  |
James[1]
Messages: 9 Registered: August 2004
|
Junior Member |
|
|
Thanks David !
But I still didn't clearly understand... I want to plot not lines,
but dots (or circles). And I have an array of data with coordinates (X,Y).
How it will work in this case ?
I tried to apply your advise but I didn't get a line across the window...
|
|
|
Re: TVimage and PlotS [message #40781 is a reply to message #40780] |
Thu, 26 August 2004 06:15  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
James writes:
> Perhaps you can help me. The problem is - I want to display
> an 2D-image and then overplot the data using PlotS. It looks
> like that:
>
> ....
> TVIMAGE, image, POSITION=pos, /KEEP_ASPECT_RATIO
> PLOTS, X,Y, COLOR=100
> ....
>
> I tried to apply DATA or DEVICE keywords but without success.
> How to make the data perfectly fitted with the image ?
PLOTS is used to draw a line in a graphics window.
If you want to draw a line on your image, you have
to know where your image *is* in the window. Since
you used TVIMAGE to display your image, you *do* know
where it is. It is positioned in the window, in
normalized coordinates, according to the "pos" variable.
So I would try to draw lines on it in the same
normalized coordinates. For example, to draw a line
from the lower-left corner of the image to the
upper-right corner:
PLOTS, [pos[0], pos[1]], [pos[1], pos[3]], /Normal
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|