On Friday, November 23, 2012 12:01:43 PM UTC+1, Helder wrote:
> On Friday, November 23, 2012 11:29:42 AM UTC+1, simona bellavista wrote:
>
>> I am trying to save a plot to eps, I use the keyword output in cgplot, but this doesn't work with overplot, because it only write to eps the portion of the plot that is being drawn. example:
>
>>
>
>>
>
>>
>
>> window,0
>
>>
>
>> cgerase
>
>>
>
>> cgplot, x, y, output='out.eps'
>
>>
>
>> cgplot, x, t, /overplot
>
>>
>
>>
>
>>
>
>> and moreover the part that is being printed to eps is not shown in window 0.
>
>>
>
>> I know I can use ps_start and ps_end, but I would like to know if there is a way that allows me to visualize the plot on x window and to print to eps at the same time.
>
>>
>
>>
>
>>
>
>> Thanx
>
>
>
> Hi,
>
> I was trying just this morning also to get this sorted.
>
> I managed to do it this way:
>
>
>
> window,0
>
> PS_Start, FILENAME='PlotExport.eps'
>
> cgerase
>
> cgplot, x, y
>
> cgplot, x, t, /overplot
>
> PS_END
>
>
>
> This works fine at first and I think it is the simplest thing you can try.
>
> I then started fiddling with the PS_Start and PS_End commands and got fancy by looking at how David does it.
>
> Well, I added slightly more complicated start and end commands (from cgPlot):
>
>
>
> ps_filename = 'PlotExport.eps'
>
>
>
> cgWindow_GetDefs, $
>
> PS_Charsize = ps_charsize, $ ; The PostScript character size.
>
> PS_FONT = ps_font, $ ; Select the font for PostScript output.
>
> PS_Decomposed = ps_decomposed, $ ; Sets the PostScript color mode.
>
> PS_Delete = ps_delete, $ ; Delete PS file when making IM raster.
>
> PS_Metric = ps_metric, $ ; Select metric measurements in PostScript output.
>
> PS_Scale_factor = ps_scale_factor, $ ; Select the scale factor for PostScript output.
>
> PS_TT_Font = ps_tt_font ; Select the true-type font to use for PostScript output.
>
> ;Set up the PostScript device.
>
> PS_Start, $
>
> CHARSIZE=ps_charsize, $
>
> DECOMPOSED=ps_decomposed, $
>
> FILENAME=ps_filename, $
>
> FONT=ps_font , $
>
> ENCAPSULATED=encapsulated, $
>
> METRIC=ps_metric, $
>
> SCALE_FACTOR=ps_scale_factor, $
>
> TT_FONT=ps_tt_font, $
>
> QUIET=1
>
>
>
> [... do the plotting here...]
>
>
>
> cgWindow_GetDefs, $
>
> IM_Density = im_density, $ ; Sets the density parameter on ImageMagick convert command.
>
> IM_Options = im_options, $ ; Sets extra ImageMagick options on the ImageMagick convert command.
>
> IM_Resize = im_resize, $ ; Sets the resize parameter on ImageMagick convert command.
>
> IM_Transparent = im_transparent, $ ; Sets the "alpha" keyword on ImageMagick convert command.
>
> IM_Width = im_width, $ ; Sets the width of raster file output created with ImageMagick.
>
> PDF_Unix_Convert_Cmd = pdf_unix_convert_cmd, $ ; Command to convert PS to PDF.
>
> PDF_Path = pdf_path ; The path to the Ghostscript conversion command.
>
> ; Close the PostScript file and create whatever output is needed.
>
> PS_END, ALLOW_TRANSPARENT=im_transparent, $
>
> DENSITY=im_density, $
>
> GS_PATH=pdf_path, $
>
> IM_OPTIONS=im_options, $
>
> RESIZE=im_resize, $
>
> UNIX_CONVERT_CMD=pdf_unix_convert_cmd, $
>
> WIDTH=im_width
>
>
>
> However, after this command, when I try to plot again on a normal window, I get strange fonts (thicker)... Still have to figure out this one.
>
>
>
> The above is not fully tested, but did the job for me pretty well!
>
>
>
> Cheers,
>
> Helder
Well, I have to say that if your final output is going to be a PS, then you don't need all the IM_* commands. You may actually only use:
ps_filename = 'PlotExport.eps'
cgWindow_GetDefs, $
PS_Charsize = ps_charsize, $ ; The PostScript character size.
PS_FONT = ps_font, $ ; Select the font for PostScript output.
PS_Decomposed = ps_decomposed, $ ; Sets the PostScript color mode.
PS_Delete = ps_delete, $ ; Delete PS file when making IM raster.
PS_Metric = ps_metric, $ ; Select metric measurements in PostScript output.
PS_Scale_factor = ps_scale_factor, $ ; Select the scale factor for PostScript output.
PS_TT_Font = ps_tt_font ; Select the true-type font to use for PostScript output.
;Set up the PostScript device.
PS_Start, $
CHARSIZE=ps_charsize, $
DECOMPOSED=ps_decomposed, $
FILENAME=ps_filename, $
FONT=ps_font , $
METRIC=ps_metric, $
SCALE_FACTOR=ps_scale_factor, $
TT_FONT=ps_tt_font, $
QUIET=1
cgPlot, cgDemoData(1)
cgPlot, findgen(101)*30.0/100.0, /overplot
;do all the overplotting before the ps_end command
PS_END
Regarding my problem with the fonts... Well, that was just a big error of mine.. I was saving the !P variable for other purposes and re-plotting set the PS conditions.
Cheers,
Helder
|