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

Home » Public Forums » archive » Plotting arrays where data points can have varying colors
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Plotting arrays where data points can have varying colors [message #85326] Wed, 24 July 2013 21:06 Go to next message
lachtantau is currently offline  lachtantau
Messages: 3
Registered: August 2012
Junior Member
Hi guys, first post but I often come here to look for similar topics!

So essentially I want to plot a 1D array for example (to keep things simple)
plot, [1,2,3,4,5], [1,2,3,4,5], psym = 4

but lets just say for arguments sake, I'd like x = 2 and x = 5 to be blue markers, and the rest to be red, is there an easy way to do this other than splitting the original array into smaller arrays and plotting separately with oplot?

I would have thought entering and array of equal size to the x and y values of colors may have worked, but I guess not...

Thanks for the help in advance!
Re: Plotting arrays where data points can have varying colors [message #85327 is a reply to message #85326] Wed, 24 July 2013 21:17 Go to previous messageGo to next message
lachtantau is currently offline  lachtantau
Messages: 3
Registered: August 2012
Junior Member
Don't worry folks, all sorted found the 'plots' procedure which does this!
Re: Plotting arrays where data points can have varying colors [message #85328 is a reply to message #85326] Wed, 24 July 2013 21:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lachlan Tantau writes:

> So essentially I want to plot a 1D array for example (to keep things simple)
> plot, [1,2,3,4,5], [1,2,3,4,5], psym = 4
>
> but lets just say for arguments sake, I'd like x = 2 and x = 5 to be blue markers, and the rest to be red, is there an easy way to do this other than splitting the original array into smaller arrays and plotting separately with oplot?
>
> I would have thought entering and array of equal size to the x and y values of colors may have worked, but I guess not...

x = [1,2,3,4,5]
y = [1,2,3,4,5]
cgPlot, x, y, /NoData
colors = StrArr(5) + 'red'
colors[[2,5]] = 'blue'
cgPlots, x, y, PSYM=4, Color=colors, Symsize=2, Thick=2
END

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to create a stable "package" in IDL?
Next Topic: smoothing spline

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

Current Time: Wed Oct 08 13:33:50 PDT 2025

Total time taken to generate the page: 0.00409 seconds