Skip to main content

7.7) Outputting The Plot


Writing a plot you have displayed in an IDL window to a png file is easy. We simply use the built-in write_png procedure:

tvlct, r, g, b, /get
write_png, 'myplot.png', tvrd(true=1), r, g, b

The call to "tvlct" gets the RGB values for the current colour table and stores them in the arrays r, g and b, which are needed for writing the png file.

The "tvrd" function simply reads the contents of the current IDL plotting window, setting the keyword (true=1) tells IDL that we want a "true colour" image.