ugly png plots in 3.1.54

Ben Abbott bpabbott at mac.com
Thu Mar 12 11:47:24 CDT 2009


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.

The top of that thread is below.

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

and on Nabble

	http://www.nabble.com/-changeset--print.m-%28matlab-compatibility%29-tt22415139.html

Ben



More information about the Bug-octave mailing list