Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axes but no lines when printing plot in Octave for windows

Tags:

plot

octave

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!

like image 578
cod3monk3y Avatar asked Apr 17 '14 05:04

cod3monk3y


People also ask

How to clear plot in Octave?

To clear the current figure, call the clf function. To clear the current axis, call the cla function. To bring the current figure to the top of the window stack, call the shg function. To delete a graphics object, call delete on its index.

How do you plot points in octave?

When plotting in Octave you plot points having their x -values stored in one vector and the y -values in another vector. The two vectors must be the same size. Octave inserts lines between the points. If you want a smoother graph, make a longer x -vector.

How do you plot a function in octave?

octave#:#> plot(x,y,'b--','linewidth',3) will plot x and y as a thick, blue, dashed line. The next example consists in plotting two different functions on the same axis. Specifically, we will plot the functions f1(x) = sin(x) and f2(x) = sin(x2) from x = 0 to x = 2π, using equally spaced points on the x-axis.


1 Answers

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.

like image 85
Andy Avatar answered Sep 22 '22 14:09

Andy