Skip to main content

3.7) Axes Ranges And Titles


The plots in the previous example didn't have any axis labels or a title. These are easily added using the "xtitle", "ytitle" and "title" keywords in the original call to plot.

plot, x, x2, psym=-1, xtitle="Some title text", ytitle="Some more title text", title="Simple plot"

You can see from the plot that the second set of data plotted goes off the top of the y-axis scale. This is because IDL automatically decides on the range to use for the scale based on the maximum value of the data used in the original call to plot. You can override this for either the x or y axis using the keywords "xrange" or "yrange" in the original call to plot.

plot, x, y, xrange=[xmin,xmax], yrange=[ymin,ymax]

Where xmin, xmax, ymin and ymax can be any floating point number. This will work fine for the x-axis but for some reason unless ymin is negative, IDL will force ymin to be zero. You can override this settings by using the keyword "ystyle=1" to force the axis to the range you specify.

So to see all of the second dataset in the example plot, edit the plotting line in simple_plot.pro to:

plot, x, x2, yrange=[0,1000], xtitle="Some title text", ytitle="Some more title text", title="Simple plot", psym=-1