Saving images/plots in CDAT
![]() |
![]() |
![]() | |
| Contents | Previous | Next |
Goal: Learn how to save plot/window in CDAT.
There are several methods and fomat files you can save your CDAT plot to. Here are some of them, for more extensive explanation see Basic Plotting Commands tutorial.
import cdms, vcs, cdutil, os, sys
# open a file to read data
filepath = os.path.join(sys.prefix, 'sample_data/ts_da.nc')
f = cdms.open( filepath)
# read data from an input file
data = f('ts')
# Initial VCS v = vcs.init()
# Plot data using the default boxfill graphics method:
v.plot(data)
Generate a postscript output file.
v.postscript('test.ps')
Generate a gif output file.
v.gif('test.gif')
Generate a cgm output file.
v.cgm('test.cgm')
Generate a raster output file.
v.raster('test.ras')
Generate a ghostscript output file.
v.gs('test.png')# generate ghostscript png output file
# generate ghostscript tiff output file
v.gs('test.tif', device = 'tiff24nc', orientation = 'l', resolution = '172.x172.')
![]() |
![]() |
![]() | |
| Contents | Previous | Next |



