It's probably rather late to put out this program, now that people are
using IDL 8 and its new graphics system, but perhaps some, like me,
are still used to the old way of making plots. With this code you can
add the most important parts that were missing: good quality screen
text, smooth curves, and matching postscript output.
Essentially, it diverts the plot commands to a large pixmap, scaling
up the character sizes, line thicknesses and everything else, and then
shrinks the result back down for display. For postscript output, the
comands are sent directly to the PS device, but introducing some
calibration factors to ensure the results appear the same as on-
screen. Additionally, there's an optional keyword to specify the
standard character size in points to recalibrate the default IDL
relative scale - this can be useful when a plot for publication
requires a specific character size.
The code, example usage, and some sample output can be found here:
http://hrscview.fu-berlin.de/mex4/software/gmwindow/
Greg
; gmwindow object
; Greg Michael 2008-2010
;
; purpose
; To produce high-quality anti-aliased screen plots using a syntax
as close as possible to the standard IDL
; direct graphics commands, and to generate identical screen and
postscript output from the same
; command sequence.
;
; requirements
; frebin() - from IDL Astronomy User's Library at http://idlastro.gsfc.nasa.gov/
; gm_oploterr - modified IDL library routine (added _extra keyword)
;
; initialisation
; Obj = OBJ_NEW('gmwindow', [keywords as for WINDOW command]
[,factor=value] [, ppcm=value] [,pt_size=value] [,pt_symsize=value]
[,filename=value])
;
; keywords as for direct graphics "window" command except:
; factor - anti-aliasing factor. Object creates a plot 'factor'
times larger than required for display. The reduction of this image to
display
; size produces intermediate pixel values on hard edges,
giving a smoother appearance. Higher values give better quality.
Default
; value is 4.
; ppcm - pixels/cm - if set, xsize,ysize understood in cm instead of
pixels; screen image will have dimensions [xsize,ysize]*ppcm
; - allows simple equivalence between ps and screen plots
; pt_size - in conjunction with ppcm, allows the standard charsize
(charsize=1) to be redefined to be a specific point size
; pt_symsize - like pt_size, but for plot symbols
; filename - postscript output filename
; supports following standard direct graphics commands as methods:
; erase, arrow, textwidth(), xyouts, oplot, plot, axis, tv, tvscl,
oploterr
;
; optionally supports these additional direct graphics routines from
David Fanning:
; symcat() (requires modified version, gm_symcat() with added _extra
keyword), histoplot
;
;
; additional keywords to graphics command methods
; no_draw - set to prevent redraw of anti-aliased window (can speed
up rendering when there any many overplots)
;
; additional methods
; save - for ps, save and close file; for screen, send to png file
; draw - redraw anti-aliased window (required only if image
constructed with no_draw keyword set)
;
;
;
;
;Example 1: Create simple screen plot
;
;device,decomposed=0
;loadct,0
;w=obj_new("gmwindow",title="gmwindow",xsize=600,ysize=400)
;w->plot,indgen(20),findgen(20)^2,psym=-5,ytitle="an axis
title",background=255,color=0,charsize=2
;w->oplot,indgen(20),400-findgen(20)^2,psym=-4,color=128
;w->xyouts,5,200,"a label",color=0,charsize=3;
;obj_destroy,w
;
;Note that after the object declaration, syntax is *exactly* as
standard IDL except for the initial w->
;
;
;
;
;Example 2: Create replica screen and postscript plots
;
;Two files are created, "example2.png" and "example2.eps" with
identical format plots usings lines, symbols (also
;a custom symbol from symcat), text labels and an image. The postscipt
image will have dimensions 6x4cm; the screen
;image will be 600x400 pixels. The standard font size is set at 6
points.
;
;
;pro Example2,output_folder
; device,decomposed=0
; loadct,0
; for ps=0,1 do begin
; ;when ps=0 make screen plot, when ps=1 do postscript...
;
w=obj_new("gmwindow",xsize=6,ysize=4,ppcm=100,pt_size=6,filename=output_folder
+"example2",ps=ps)
;
; w->plot,indgen(20),findgen(20)^2,psym=-5,ytitle="an axis
title",background=255,color=0
; w->oplot,indgen(20),400-findgen(20)^2,psym=-(w-
> symcat(11)),color=128
; w->xyouts,5,200,"a label",color=0,charsize=1.5
; w->tvscl,dist(50),10,10
; w->save
; obj_destroy,w
; endfor
;end
;
;Example2,"d:\mydocs\tmp\"
|