comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » 2D array as colour dot image
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: 2D array as colour dot image [message #82831 is a reply to message #82704] Tue, 15 January 2013 10:06 Go to previous messageGo to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
Hi Mark,

How about something like this, using New Graphics?

F1 = RANDOMN(seed, 10000000)
F2 = f1 + RANDOMN(seed, 10000000)
Result = HIST_2D(F1, F2, MIN1=-2, MAX1=2.001d, $
MIN2=-2, MAX2=2.001d, BIN1=0.05d, BIN2=0.05d)
; HIST_2D seems to include a column & row of all zeroes. Remove it.
Result = Result[0:-2, 0:-2]
x = -2 + 0.05d*FINDGEN(80)
y = x
print, min(result, max=mx), mx

i = IMAGE(result, x, y, RGB_TABLE=74, AXIS_STYLE=1, $
XTITLE='X data', YTITLE='Y data', POSITION=[0.1,0.1,0.8,0.84], $
TITLE='Ran1 vs (Ran1+Ran2)')
!null = COLORBAR(TARGET=i, /ORIENTATION, $
TITLE='Magnitude', TEXTPOS=1, $
POSITION=[0.82,0.1,0.87,0.84])
c = CONTOUR(result, x, y, /OVERPLOT)

i.Save, 'scatter.png', RESOLUTION=96, BORDER=10

Obviously, you would need to change the HIST_2D inputs, and I just hardcoded the X and Y variables.

This should create a scatter plot, colored by "magnitude", which here is just the number of samples in each bin in the 2D histogram. Then I added a colorbar on the right side, and a contour plot with labels.

Note that this example requires IDL 8.2.1.

Regarding the speed difference between direct and new graphics: for direct graphics the surface is just "burned" into the window, so it only has to draw it once. For new graphics, the image (or surface) is a dynamic object, which can be manipulated after creation.

Hope this helps!

-Chris
ExelisVIS
p.s. here's a screenshot of the resulting graphic:
http://www.flickr.com/photos/79705059@N06/8383412553/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: interpolating flux
Next Topic: how to convert a row of data in a column?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:14:10 PDT 2025

Total time taken to generate the page: 0.02987 seconds