ugly png plots in 3.1.54

Ben Abbott bpabbott at mac.com
Thu Mar 12 18:23:54 CDT 2009


On Mar 13, 2009, at 1:02 AM, John W. Eaton wrote:

> On 13-Mar-2009, Ben Abbott wrote:
>
> | On Mar 12, 2009, at 11:24 PM, Francesco Potorti` wrote:
> |
> | > When printing a plot with print("file.png") the plot is in  
> portrait
> | > mode.
> | >
> | > Until 3.1.51, the default PNG size was a sane 640x480.  In  
> 3.1.52 it
> | > became 576x432, that is, 90% than before.  In 3.1.54 it is  
> 612x792,
> | > which is portrait and does not fit well with the landscape  
> format of
> | > gnuplot's plots.  The relevant gnuplot line is:
> | >
> | >  set terminal png enhanced size 612,792 large;
> |
> | This is intentional. We've improved compatibility with Matlab.
> |
> | 	http://hg.savannah.gnu.org/hgweb/octave/rev/665b264b6a50
> |
> | > For both PNG and SVG, forcing 640x480 by using
> | > print("file.png","-dpng","-S640,480") produces somewhat squashed
> | > plots,
> | > with too big margins on top and bottom of the plots.
> |
> | The "squashed" behavior is due to the "paperposition" property.
> |
> | Try
> |
> | 	set (gcf, "paperposition", [0 0 get(gcf,"papersize")])
> | 	print("file.png","-dpng","-S640,480")
> |
> | ... but you'll get better results with,
> |
> | 	set (0, "defaultaxesfontsize", 12)
> | 	set (0, "defaulttextfontsize", 12)
> | 	set (0, "defaultaxesfontname", "*")
> | 	set (0, "defaulttextfontname", "*")
> | 	figure (1)
> | 	clf
> | 	plot (0:10)
> | 	xlabel ("xlabel")
> | 	ylabel ("ylabel")
> | 	title ("title")
> | 	set (gcf, "paperunits", "inches")
> | 	set (gcf, "papersize", [6.4, 4.8])
> | 	set (gcf, "papertype", "<custom>")
> | 	set (gcf, "paperposition", [0, 0, 6.4, 4.8])
> | 	print (gcf, "-dpng", "-r100", "test_100dpi.png")
> |
> | There is a changeset in work that will improve the positioning of  
> the
> | tick-labels, axes-labels and title. It will also produce a font with
> | the proper size on the page.
>
> OK.
>
> When we are done, will it be necessary to do all these things to get
> reasonble looking output?  Is it required when using Matlab?
> Shouldn't we be able to get reasonable looking output by default,
> without having to specify a lot of properties?
>
> jwe

I've started looking at implementing some listeners for "papertype",  
"papersize", "paperunits", and "paperposition". As well as listeners  
for all "units" and "fontunits" properties. The root's  
"screenpixelsperinch" is included as well (as units conversion relies  
upon it)

I had made some comments on this at the link below

	http://www-old.cae.wisc.edu/pipermail/octave-maintainers/2009-March/011405.html

My initial implementation will be as an m-file (mostly written but  
needs to be debugged). I'll post it for comment after its been debugged.

With the listeners in place the behavior will be like Matlab. Meaning  
that it is only necessary to specify "papersize" or "papertype" and  
"paperposition".

For Francesco's case, I'll look at handling all the figure's "paper*"  
properties in a reasonable way.

Ben


More information about the Bug-octave mailing list