Reputation: 375
I want to create pdf or png plots from octave on an ubuntu system where I just have a command line, no X11, no windows. I want to do something like this:
plot(x, y);
print -dpng myplot.png
But plot gives me this warning:
warning: X11 DISPLAY environment variable not set
And both commands just give me a character graphic rendition on the console. Do I need to set GNUTERM to something?
Upvotes: 3
Views: 1216
Reputation: 1013
This is a really old question but it was the top result for me. Relevant for today's cloud services, here are ways to approach the problem:
figure ("visible", "off")
plot (1:10)
print output.png
If you don't want to work just with files, X11 can be forwarded for remote viewing. Run Octave remotely and display locally via x11 assumes the X11 libraries are installed and ready to go...so just add -X to ssh:
ssh -X remoteserver
To get X11 there in the first place, these articles:
suggest:
and just in case you indeed run into a GNUTERM error: Octave Plotting Error suggests compiling gnuplot with X11 support and setting the environment before plotting anything:
$ (whatever installs) gnuplot --with-x11
Then in Octave:
#setenv("GNUTERM", "qt")
setenv("GNUTERM","X11")
plot(x,y)
Upvotes: 3