10
votes

When attempting to print a plot to .png in Octave 3.8.1.1 on Windows 8 64-bit, the axes plot, but the line I'm plotting won't print. The plot I'm creating is:

> t = 0:0.1:6.28318;
> plot (t, sin(t));
> print figure.png

The resulting plot:

enter image description here

And the image saved to disk:

enter image description here

So the axes are showing up fine, but the line I've plotted is completely missing!

I have gs9.09 (win32) installed, with epstool win32 copied into gs's /bin directory, which is being set in my %HOMEPATH%\.octaverc as:

cmd_path = getenv ("path");
gs_path = 'C:\Programs\gs\gs9.09\bin';
if (isempty (strfind (cmd_path, gs_path)))
   setenv ('path', strcat (cmd_path, pathsep (), gs_path));
endif

I am running the windows GUI version via w8-octave-gui.bat.

EDIT On a fresh launch with the following commands to set gnuplot as the graphics toolkit before launching any plots (from @Andy's comments), I get a blank white image for all images without -dpngalpha (1, 2, 4, 5) and completely transparent images with no content for images with -dpngalpha (3, 6):

>> graphics_toolkit("gnuplot");
>> graphics_toolkit()
ans = gnuplot
>> t = 0:0.1:6.3;
>> plot(t,sin(t));
>> print ("1.png");
>> print ("-dpng", "2.png");
>> print ("-dpngalpha", "3.png");
>> axis("off");
>> print ("4.png");
>> print ("-dpng", "5.png");
>> print ("-dpngalpha", "6.png");

Halp!

2
Have you tried with a different graphics_toolkit?am304
Congrats for this well-written question. Adding to @am304's comment, please also try with alternative syntax: print ('figure.png','-dpng').juliohm
@am304 - I wasn't aware of that option, thank you. Using available_graphics_toolkits() lists gnuplot and fltk on my system. Switching to gnuplot I can succesfully print only .emf files, and can send the plot to my printer (progress!). Every other format I tried with gnuplot prints a blank white image (.png, .pdf, .jpg). When I try .gif the application crashes (if saving from the plot window) or reports the gnuplot terminal, "gif", is not available if run from the command window. -- I would ideally like .png output, any thoughts on that?cod3monk3y
@juliohm - thanks! using the alternative syntax had no effect with either fltk or gnuplot.cod3monk3y
@cod3monk3y, consider a bug report.juliohm

2 Answers

2
votes

Looks like you've hit this bug: https://savannah.gnu.org/bugs/?42534

I know you answered to juliohm's comment that switching to gnuplot doesn't has an effect but I can't believe this. You have to execute graphics_toolkit("gnuplot") before any command which creates a plot figure. To be sure you can run "close all" before.

The reason for your problem is possibly that the line is printed behind the white background due to some rounding errors in the z-depth. Can you please try EDIT: these command when graphics_toolkit fltk is enabled (should be the case with a default install and a fresh start):

t = 0:0.1:6.28318;
plot (t, sin(t));
axis ("off");
print ("-dpngalpha", "out.png")

to verify this? This doesn't solve your problem but helps the Octave maintainers to find the problem.

0
votes

I encountered the same problem.

For me the solution was bypassing the system graphics driver and switching to OpenGL software rendering with Mesa. To achieve this I downloaded the windows binary of Mesa that is linked on http://qt-project.org/wiki/Cross-compiling-Mesa-for-Windows and copied the included opengl32.dll into octave's bin directory. Afterwards the print command worked fine.

The Mesa binary from the link above is built with LLVMpipe and seems to run reasonably fast.