Re: Shading plotting symbols [message #78931] |
Sun, 08 January 2012 11:21 |
Jack Frost
Messages: 2 Registered: January 2012
|
Junior Member |
|
|
On Jan 8, 4:24 pm, Russell <rryan....@gmail.com> wrote:
> This is pretty straight-forward, and David's cg* library will do the
> trick. But just in case, you prefer to roll your own (even when
> stable alternatives exist), here's what I would do:
>
> lo=[1,2,3,4,5] ;the lower-bounds of your color segments
> hi=[2,3,4,5,6] ;the upper-bounds of your color segments
> psym=2
>
> ;the colors
> colors=findgen(n_elements(lo))/(n_elements(lo)-1)*200+55
>
> xr=[0,360] ;lon range
> yr=[-90,90] ;lat range
> plot,[0],[0],/nodata,xr=xr,yr=yr,xst=5,yst=5 ;just define the conv
> between data/device/normal coord
>
> loadct,13,/silent ;load the color table of your choice, 13 is a
> rainbow...
> for i=0,n_elements(lo)-1 do begin ;for every color segment do
> something:
> ; find the good data to plot, you should change this logic as
> necessary
> g=where(val gt lo(i) and val le hi(i),n)
> if n gt 0 then oplot,lon(g),lat(g),color=color(i),psym=psym
> endfor
> loadct,0,/silent ;switch back to B&W
>
> plot,[0],[0],/nodata,xr=xr,yr=yr,xst=1,yst=1 ;overplot the axes
>
> On Jan 8, 9:56 am, Jack Frost <jf22...@gmail.com> wrote:
>
>
>
>
>
>
>
>> Hi all.
>
>> I was wondering if it was possible to shade plotting symbols different
>> colors? For example, say I have a latitude-longitude plot of the
>> Earth, with x symbols showing the locations where some measurements
>> were taken. Is it possible to shade these symbols to show the value of
>> the measurement, i.e measurements with values between 1-2 are blue,
>> 2-3 are green, 3-4 are red etc?
>
>> At the moment I am just creating a plot of measurement locations from
>> the 1d lat/lon arrays as such:
>
>> plot, lon, lat, psym=1, $
>> xrange=[0,360], yrange=[-90,90], $
>> xtitle='Longitude', ytitle='Latitude', $
>> xticks=4, xtickname=['0','90','180','270','360'], $
>> yticks=6, ytickname=['-90','-60','-30','EQ','30','60','90'], $
>> title='Locations of retrievals'
>> filename='ice_locations.png'
>> write_png,filename,tvrd()
>
>> Many thanks,
>
>> Jack
Brilliant, thanks guys!
I'm using Russell's method at the moment, as I'm on my home computer
which has GDL and I keep getting errors when trying to find GDLs color
tables with cgloadct. However, when I'm back at uni tomorrow I'll give
David's method a whirl.
The more I use IDL, the more I realize I know nothing about IDL! :)
|
|
|
Re: Shading plotting symbols [message #78932 is a reply to message #78931] |
Sun, 08 January 2012 08:24  |
Russell[1]
Messages: 101 Registered: August 2011
|
Senior Member |
|
|
This is pretty straight-forward, and David's cg* library will do the
trick. But just in case, you prefer to roll your own (even when
stable alternatives exist), here's what I would do:
lo=[1,2,3,4,5] ;the lower-bounds of your color segments
hi=[2,3,4,5,6] ;the upper-bounds of your color segments
psym=2
;the colors
colors=findgen(n_elements(lo))/(n_elements(lo)-1)*200+55
xr=[0,360] ;lon range
yr=[-90,90] ;lat range
plot,[0],[0],/nodata,xr=xr,yr=yr,xst=5,yst=5 ;just define the conv
between data/device/normal coord
loadct,13,/silent ;load the color table of your choice, 13 is a
rainbow...
for i=0,n_elements(lo)-1 do begin ;for every color segment do
something:
; find the good data to plot, you should change this logic as
necessary
g=where(val gt lo(i) and val le hi(i),n)
if n gt 0 then oplot,lon(g),lat(g),color=color(i),psym=psym
endfor
loadct,0,/silent ;switch back to B&W
plot,[0],[0],/nodata,xr=xr,yr=yr,xst=1,yst=1 ;overplot the axes
On Jan 8, 9:56 am, Jack Frost <jf22...@gmail.com> wrote:
> Hi all.
>
> I was wondering if it was possible to shade plotting symbols different
> colors? For example, say I have a latitude-longitude plot of the
> Earth, with x symbols showing the locations where some measurements
> were taken. Is it possible to shade these symbols to show the value of
> the measurement, i.e measurements with values between 1-2 are blue,
> 2-3 are green, 3-4 are red etc?
>
> At the moment I am just creating a plot of measurement locations from
> the 1d lat/lon arrays as such:
>
> plot, lon, lat, psym=1, $
> xrange=[0,360], yrange=[-90,90], $
> xtitle='Longitude', ytitle='Latitude', $
> xticks=4, xtickname=['0','90','180','270','360'], $
> yticks=6, ytickname=['-90','-60','-30','EQ','30','60','90'], $
> title='Locations of retrievals'
> filename='ice_locations.png'
> write_png,filename,tvrd()
>
> Many thanks,
>
> Jack
|
|
|
Re: Shading plotting symbols [message #78933 is a reply to message #78932] |
Sun, 08 January 2012 08:05  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jack Frost writes:
> I was wondering if it was possible to shade plotting symbols different
> colors? For example, say I have a latitude-longitude plot of the
> Earth, with x symbols showing the locations where some measurements
> were taken. Is it possible to shade these symbols to show the value of
> the measurement, i.e measurements with values between 1-2 are blue,
> 2-3 are green, 3-4 are red etc?
>
> At the moment I am just creating a plot of measurement locations from
> the 1d lat/lon arrays as such:
>
> plot, lon, lat, psym=1, $
> xrange=[0,360], yrange=[-90,90], $
> xtitle='Longitude', ytitle='Latitude', $
> xticks=4, xtickname=['0','90','180','270','360'], $
> yticks=6, ytickname=['-90','-60','-30','EQ','30','60','90'], $
> title='Locations of retrievals'
> filename='ice_locations.png'
> write_png,filename,tvrd()
Yes, of course. Here is an example of how you can
color plot values:
http://www.idlcoyote.com/graphics_tips/coloredline.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|