Plotting arrays where data points can have varying colors [message #85326] |
Wed, 24 July 2013 21:06  |
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 #85328 is a reply to message #85326] |
Wed, 24 July 2013 21:20  |
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.")
|
|
|