How do you do an x-y line plot?
First the good news: If you're willing to settle for a basic line plot, this is pretty easy. Say you have the following data (points along a sine curve):
import Numeric as N
x = N.arange(17)*N.pi/8.
y = N.sin(x)
Then this will give you the x-y plot:
v = vcs.init()
v.xvsy(x, y, 'default', 'default', name='Sine Curve')
'default' arguments refer to the
that are used.
name gives the title of the plot.
Now the bad news: Even a slightly more complex line plot (say, one that includes axis titles) is a lot more work. In order to make one, we have to understand how to use graphics methods and templates, text objects, and coordinate systems on the canvas. I put these ideas together in my complex line plot example.
A side note: If you want to do an x-y plot of a section of a
cdms data object, with a latitude or longitude
dimension, make sure that you specify the data from the
latitude/longitude dimension, and not the axis object.
Ray Pierrehumbert provides
more information on this
Python Lectures for Climate Science.
Notes: This discussion applies to CDAT 3.3.