pro testplot
; Generate a thousand numbers from 0 to 2*pi:
zero_to_2pi=indgen(1001)/500.0*!pi
; Calculate the sine of each of the list of numbers:
sine=sin(zero_to_2pi)
; Tell imopen to open a portable network graphics ("png") file "test.png":
imopen,'png',fn='test'
; The 'png' tells imopen the file format. The fn='test' tells imopen the
; file's basename -- the portion of the filename that comes before the last '.'
; Later, when you call imclose, imclose will generate the file "test.png".
; It makes that filename by appending a "." and the name of the file format
; ("png") to the end of your file's basename ("test" from fn='test').
; Plot sin(x) with x=0..2*pi:
plot,zero_to_2pi,sine
; Tell imclose to copy everything we plotted between imopen and
; imclose to the test.png file and close that file:
imclose
end