Re: 3D data on a color coded line plot! [message #86205 is a reply to message #86203] |
Thu, 17 October 2013 08:42   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
steve.daal@gmail.com writes:
> I thought this would be an easy thing to do, but seems I am missing or
overseeing something!
>
> I have 3D data: density, pressure, and time.
> I want to plot time vs density, with the pressure as a color code on the density trace.
> Coyote's time vs elevation example doesn't work, since its 2D, and the colors are just over plotted, meaning that the red color would only be at the upper values of time (X axis) or elevation (Y axis).
> In my case, the color coded data is independent, so the red could be at any place in the plot.
> How to do that?!
It *is* easy to do. It is just a simple variation of the colored line
plots shown in the Coyote Plot Gallery.
density = cgDemoData(1)
pressure= cgDemoData(17)
time = cgScaleVector(Findgen(N_Elements(density)), 0, 6)
thick = (!D.Name EQ 'PS') ? 6 : 3
cgDisplay
pressureColors = BytScl(pressure)
cgPlot, time, density, /NoData, XTitle='Time', $
YTitle='Density', Label='Colored by Pressure'
FOR j=0,N_Elements(pressure)-2 DO cgPlotS, $
[time[j], time[j+1]], [density[j], density[j+1]], $
Color=pressureColors[j], Thick=thick
FOR j=0,N_Elements(pressure)-1,2 DO cgPlotS, $
time[j], density[j], PSym=2, $
SymSize=1.5, Color=pressureColors[j]
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.")
|
|
|