Discussion:
how does one get Octave and GNUplot to work on a Mac?
(too old to reply)
robert bristow-johnson
2009-01-27 21:24:54 UTC
Permalink
hi,

i've used Octave before on a Linux machine and am pretty well versed
with MATLAB. i downloaded all that i thought i was required to to get
Octave for this laptop Mac (PPC, OSX):

System Version: Mac OS X 10.4.11 (8S165)
Kernel Version: Darwin 8.11.0



to test i tried to plot a simple graph:


___________________________________

Last login: Tue Jan 27 16:10:18 on ttyp1
Welcome to Darwin!
robert-s-powerbook-g4-15:~ robert$ exec '/Applications/Octave.app/
Contents/Resources/bin/octave'
GNU Octave, version 3.0.2
Copyright (C) 2008 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.

Octave was configured for "powerpc-apple-darwin7.9.1".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Report bugs to <***@octave.org> (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful
report).

For information about changes from previous versions, type `news'.

octave-3.0.2:1> x = linspace(0,1,4097);
octave-3.0.2:2> y = x.^2;
octave-3.0.2:3> plot(x,y);
octave-3.0.2:4>

___________________________________



before i started up Octave, i started up gnuplot, but i typed in no
commands (i don't really know anything about gnuplot):


___________________________________


Last login: Tue Jan 27 15:38:10 on ttyp1
exec '/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot'


Welcome to Darwin!
robert-s-powerbook-g4-15:~ robert$ exec '/Applications/Gnuplot.app/
Contents/Resources/bin/gnuplot'

G N U P L O T
Version 4.2 patchlevel 3
last modified Mar 2008
System: Darwin 8.11.0

Copyright (C) 1986 - 1993, 1998, 2004, 2007, 2008
Thomas Williams, Colin Kelley and many others

Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from http://www.gnuplot.info/faq/

Send bug reports and suggestions to <http://sourceforge.net/
projects/gnuplot>


Terminal type set to 'aqua'
gnuplot>

____________________________________




it appears that i *do* get these Octave arrays, "x" and "y", and the
call to plot() came back with no diagnostics, but i got no window with
any plot in it. what more must i do to get this to work? are there
any Mac Octave users out there that can help me?

thanks for any help. feel free to ask me about any DSP questions
(that's something i'm pretty good at, but i am no good at getting
sparsely documented software to work) in exchange.

r b-j
Francesco Potortì
2009-01-28 08:18:45 UTC
Permalink
Post by robert bristow-johnson
thanks for any help.
It appear sthat you have already received help on the octave mailing
list, right?
robert bristow-johnson
2009-01-28 17:31:04 UTC
Permalink
Post by Francesco Potortì
Post by robert bristow-johnson
thanks for any help.
It appear sthat you have already received help on the octave mailing
list, right?
no. in fact, i hadn't seen anything from there. maybe i'm missing
something.

r b-j
robert bristow-johnson
2009-01-28 19:04:01 UTC
Permalink
Post by Francesco Potortì
Post by robert bristow-johnson
thanks for any help.
It appear sthat you have already received help on the octave mailing
list, right?
okay, i did take a look at the Octave Help Mailing list and found this
thread:

Help with plot on Macbook

and found this advice:

_______________________

You've installed a binary package that exists in your Applications
folder. It is not easily run from a terminal.

My understanding is that for OSX 10.4 you'll need to start x11 prior
to running octave in order for gnuplot to display the figures.

so ...

(1) Start x11 (it is in /Applications/Utilities)
(2) Start Octave (it is in /Applications)
(3) type "plot (1:10)"

Do you get a figure?

If not you *may* need to set the environment variable "display".
Although I'd expect this has already be taken care of.

If you desire to run octave directly from the command line of the
Terminal, or from an xterm (they are different), I'd suggest you
install octave via MacPorts or Fink.

_______________________


and followed steps 1, 2, and 3 and still no plot. or any other window
other than the windows created when i started up X11 and Octave. i
seem to have no environment variable named "display" and i have
absolutely no idea what MacPorts or Fink are.

i saw that Julius Smith has contributed to the thread and he's an
acquaintance of mine, so i might email him directly. what i need is
someone, with a Mac OS10.4.xx, to tell me step by step, what i need to
run Octave, where to get what i need, and precisely the installation
method. i thought just following the directions on the Mac install
page (getting Octave and gnuplot) would be enough, but it evidently is
not.

r b-j
c***@gmail.com
2009-01-28 21:38:23 UTC
Permalink
One observation that may help is the default terminal of your gnuplot
installation is "aqua".

For this to work you need to have installed aquaterm (sourceforge.net)
and have it running.
Otherwise, as noted in a prior post, you can use X11.app, but it must
be running and the terminal must be set to "x11" in gnuplot (set term
x11).

HTH
robert bristow-johnson
2009-01-29 00:07:41 UTC
Permalink
Post by c***@gmail.com
One observation that may help is the default terminal of your gnuplot
installation is "aqua".
which means what?
Post by c***@gmail.com
For this to work you need to have installed aquaterm (sourceforge.net)
and have it running.
i'll look for it.
Post by c***@gmail.com
Otherwise, as noted in a prior post, you can use X11.app, but it must
be running and the terminal must be set to "x11" in gnuplot (set term
x11).
okay, i did that and here's the result:

____________________________



Last login: Wed Jan 28 19:00:46 on ttyp3
exec '/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot'
Welcome to Darwin!
robert-s-powerbook-g4-15:~ robert$ exec '/Applications/Gnuplot.app/
Contents/Resources/bin/gnuplot'

G N U P L O T
Version 4.2 patchlevel 3
last modified Mar 2008
System: Darwin 8.11.0

Copyright (C) 1986 - 1993, 1998, 2004, 2007, 2008
Thomas Williams, Colin Kelley and many others

Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from http://www.gnuplot.info/faq/

Send bug reports and suggestions to <http://sourceforge.net/
projects/gnuplot>


Terminal type set to 'aqua'
gnuplot> set term x11
Terminal type set to 'x11'
Options are '0'
gnuplot>
gnuplot: unable to open display ''
gnuplot: X11 aborted.


____________________________


i'll try to be patient (i don't look gift horses in the mouth) but i
really wonder what kind of hacking this is.

thank you for the help. i'll let the group know when/if i get this to
work and what i had to do to get it to work.

r b-j
c***@gmail.com
2009-01-29 15:45:35 UTC
Permalink
Sorry for not making this clear.

The default terminal for gnuplot is x11 since it is the graphics layer
common to *nix systems.
While Macs do not use x11 (quartz instead), it is included (X11.app)
as an option on the system install disk.
This is essential for running programs with *nix lineage (like
gnuplot) without rewriting the graphics code.

To get the graphics to work with these programs, x11 must already be
and the DISPLAY variable must be set in your environment.
This was mentioned earlier in this thread (excerpt from the octave
mailing list).

I'll assume your using the default shell on the Mac (bash) and your
starting octave from Terminal.app.

The set DISPLAY, place the following code in a file
named .bash_profile (*) in your home directory.
This tells programs where to send its graphics.
I believe this is the source of your error (unable to open display).

if [ -z ${DISPLAY} ]
then
export DISPLAY=:0.0
fi

Start a new Terminal.app window (reload .bash_profile), do the "set
term x11" thing, and it should work.

(*) google "bash reference manual", in the manual look for "6.2 Bash
Startup Files"

--

Regarding your last comment, this is the correct use of gnuplot (and
all x11 programs).

For reasons I do not appreciate, the gnuplot developers decided to
make a Mac version that, instead of using x11, it defaults to
something called aqua (http://sourceforge.net/projects/aquaterm). In
the sources, when building on a Mac, it compiles differently to make
this happen.

I personally don't like it (why opt for something non-standard and non-
portable).
To get a standard gnuplot I go in and cut the offending build
instructions out.
robert bristow-johnson
2009-01-30 22:15:24 UTC
Permalink
Post by c***@gmail.com
Sorry for not making this clear.
The default terminal for gnuplot is x11 since it is the graphics layer
common to *nix systems.
While Macs do not use x11 (quartz instead), it is included (X11.app)
as an option on the system install disk.
This is essential for running programs with *nix lineage (like
gnuplot) without rewriting the graphics code.
To get the graphics to work with these programs, x11 must already be
and the DISPLAY variable must be set in your environment.
This was mentioned earlier in this thread (excerpt from the octave
mailing list).
I'll assume your using the default shell on the Mac (bash) and your
starting octave from Terminal.app.
The set DISPLAY, place the following code in a file
named .bash_profile (*) in your home directory.
This tells programs where to send its graphics.
I believe this is the source of your error (unable to open display).
if [ -z ${DISPLAY} ]
then
  export DISPLAY=:0.0
fi
Start a new Terminal.app window (reload .bash_profile), do the "set
term x11" thing, and it should work.
(*) google "bash reference manual", in the manual look for "6.2 Bash
Startup Files"
--
Regarding your last comment, this is the correct use of gnuplot (and
all x11 programs).
For reasons I do not appreciate, the gnuplot developers decided to
make a Mac version that, instead of using x11, it defaults to
something called aqua (http://sourceforge.net/projects/aquaterm).  In
the sources, when building on a Mac, it compiles differently to make
this happen.
I personally don't like it (why opt for something non-standard and non-
portable).
To get a standard gnuplot I go in and cut the offending build
instructions out.
okay, it worked *once*.

i used Xcode to create and save the file .bash_profile to my home
directory, launched gnuplot (from the Finder), typed "set term x11",
then launched Octave (from the Finder), created my x and y arrays,
invoked plot(x,y); and it threw up a window with a plot.

then i closed all the windows, restarted the Mac, and repeated the
above with the exception of the re-creating the .bash_profile file.
since it's an invisible file and Xcode seems too dumb to open
invisible files, i checked the content of .bash_profile with vi and it
says:


if [ -z ${DISPLAY} ]
then
export DISPLAY=:0.0
fi


(now i dunno what existed in .bash_profile before, i am not even sure
there was a previous .bash_profile, i don't recall Xcode asking me
about overwriting it, so i have no idea if there were previous
settings in a possible previous .bash_profile that were lost - does
anyone here know what might be the "default version" of
the .bash_profile for someone who install Xcode, Terminal, and Console
from scratch?)



but now when i launch gnuplot and say "set term x11" it craps out:


____________________________

Last login: Fri Jan 30 16:50:07 on ttyp1
Welcome to Darwin!
new-host-3:~ robert$ exec '/Applications/Gnuplot.app/Contents/
Resources/bin/gnuplot'

G N U P L O T
Version 4.2 patchlevel 3
last modified Mar 2008
System: Darwin 8.11.0

Copyright (C) 1986 - 1993, 1998, 2004, 2007, 2008
Thomas Williams, Colin Kelley and many others

Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from http://www.gnuplot.info/faq/

Send bug reports and suggestions to <http://sourceforge.net/
projects/gnuplot>


Terminal type set to 'aqua'
gnuplot> set term x11
Terminal type set to 'x11'
Options are '0'
gnuplot>
gnuplot: unable to open display ':0.0'
gnuplot: X11 aborted.

____________________________


now that .bash_profile is correctly (i hope) configged, can you (or
anyone) tell me what i am doing wrong?

do you think i should get Aquaterm? i'll have to get the gnuplot
"adapter", should i also get the PLPLOT or PGPLOT systems, if i ever
expect to write C/C++ programs with Xcode?

just FYI, although i am well-versed with MATLAB syntax and have used
Octave before (on a linux fedora machine) and am very well versed with
C (and a little bit with C++), i just want to be able to write MATLAB/
Octave programs as simply as possible with the fewest of all the
extras i have to get, learn, and maintain. please, can someone spell
out where i can read the fundamentals of how to do this. what must i
do to use Octave on my Mac??? (icing on the cake would be help in
writing a simple Terminal or Console I/O in C/C++ on the Mac, and
beyond the call of duty would be help in calling a simple plotting
library from C on the Mac.)

back in the old THINK C/CodeWarrior days, i was able to write console
C programs readily (even legit Mac apps with QuickDraw, menus,
controls, etc), but i can't even seem to get in the front door with my
Mac and Xcode these days.

i don't want to ask for too much free help, but if someone can help me
just to get Octave/gnuplot to work. then i'll bother someone else to
help me get a simple "hello, world" program to work.

thanks in advance,

r b-j
c***@gmail.com
2009-01-31 05:43:47 UTC
Permalink
Looking at the error message, I suspect X11.app wasn't running when
you started gnuplot.

If you want to run gnuplot from within C code look into the popen()
function (stdio.h).
With popen() you can start gnuplot and write commands to it using the
FILE * it returns.
When your done, be sure to close it with pclose().

For your C program to find gnuplot, its path must be included in your
PATH variable (or hard code the absolute path).
To do this add to your .bash_profile:

PATH="${PATH}:/path/to/gnuplot"

You will need to start a new Terminal.app session for this to take
effect.

You can test your path using the following:
$ which gnuplot


Be aware that if you start Xcode by d-clicking its icon or .xcodeproj
file it will not inherit your shell environment (your .bash_profile
settings) and the debugger will fail to find gnuplot.
Instead, you need to create a ~/.MacOSX/environment.plist file
(annoying, I know).

Read these links.
http://developer.apple.com/qa/qa2001/qa1255.html
http://developer.apple.com/qa/qa2001/qa1067.html

As an example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PATH</key>
<string>/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/
Users/chad/bin</string>
</dict>
</plist>

You will need to log out and back in again for this to take effect.


Otherwise, start Xcode from Termnal.app like this:
$ open -a Xcode

Either way, Xcode will not perform any expansion (e.g. ${} or ~) (even
more annoying).
robert bristow-johnson
2009-01-31 19:40:45 UTC
Permalink
Post by c***@gmail.com
Looking at the error message, I suspect X11.app wasn't running when
you started gnuplot.
yup, yer right. i got so distracted by the gnuplot and .bash_profile
and "set term x11" that i forgot about running X11.

so i got Octave to plot again. i didn't need to run ("d-click")
gnuplot,
but i didn't run X11. i found that i didn't need to do the "set term
x11"
command. all i needed to do is d-click X11 before d-clicking
Octave.
originally that is what i did, but i didn't have that "export DISPLAY=:
0.0" thing happening. now i know that .bash_profile is a UNIX script
that runs when i launch Terminal (and i think that happens
automatically when Octave is launched), and i know what "if" and "fi"
are, but what is this DISPLAY system variable? what does

if [ -z ${DISPLAY} ]
then
export DISPLAY=:0.0
fi

do and why does that make the difference between Octave plotting via
gnuplot via X11 and this not happening? also, i am afraid i wrote
over the original .bash_profile. do you know with a freshly installed
OS10.4.xx system and Developer folder (Xcode Tools 2.2.1), did
the .bash_profile file exist. if so, was there a default content to
the file? if there was, all of the things it used to do, it doesn't
do now because i was unable to open such a file with Xcode. also, do
you know how to get Xcode to read invisible files? i really don't
want to deal with vi if i can avoid it.

one more question: how can i copy the graphic from the X11 window
with the plot in it? i want to be able to copy plots and paste them
into either Word docs or AppleWorks docs. i can't seem to do that.
Post by c***@gmail.com
If you want to run gnuplot from within C code look into the popen()
function (stdio.h).
With popen() you can start gnuplot and write commands to it using the
FILE * it returns.
When your done, be sure to close it with pclose().
For your C program to find gnuplot, its path must be included in your
PATH variable (or hard code the absolute path).
PATH="${PATH}:/path/to/gnuplot"
You will need to start a new Terminal.app session for this to take
effect.
$ which gnuplot
Be aware that if you start Xcode by d-clicking its icon or .xcodeproj
file it will not inherit your shell environment (your .bash_profile
settings) and the debugger will fail to find gnuplot.
it seemed to work (fresh from start up) for me using Octave in this
instance.

1. power up Mac (with .bash_profile configged as above)
2. launch X11 (from dock, should be equiv to d-clicking)
3. launch Octave from dock.
4. plot(...); creates window with plot in it.

i think Octave opens a terminal window with my home directory as the
default directory and the .bash_profile gets runned at that time.
Post by c***@gmail.com
Instead, you need to create a ~/.MacOSX/environment.plist file
(annoying, I know).
Read these links.
http://developer.apple.com/qa/qa2001/qa1255.html
http://developer.apple.com/qa/qa2001/qa1067.html
when i get around to trying to do something in C (that's another huge
nut to crack), i will look at that (and this post again). thank you,
very much. right now i will first try to make sure i can be
productive with Octave.

again, thank you much. perhaps i can pay you back with help regarding
math/signal_processing. i hang at comp.dsp a lot.

bestest,

r b-j
Francesco Potortì
2009-02-01 18:39:17 UTC
Permalink
Post by robert bristow-johnson
now i know that .bash_profile is a UNIX script
that runs when i launch Terminal (and i think that happens
automatically when Octave is launched), and i know what "if" and "fi"
are, but what is this DISPLAY system variable? what does
if [ -z ${DISPLAY} ]
then
export DISPLAY=:0.0
fi
do and why does that make the difference between Octave plotting via
gnuplot via X11 and this not happening?
I do not use a Mac, but: the DISPLAY shell variable (bash is a shell)
indicates that the X server is running and where it is. The ":0.0"
value means that it is running on the same machine in the default
place. The code lines that you wrote mean that, if the DISPLAY variable
is not already set, it is set to ":0.0".
Post by robert bristow-johnson
over the original .bash_profile. do you know with a freshly installed
OS10.4.xx system and Developer folder (Xcode Tools 2.2.1), did
the .bash_profile file exist. if so, was there a default content to
the file?
Sorry, I can not help you here.
Post by robert bristow-johnson
one more question: how can i copy the graphic from the X11 window
with the plot in it? i want to be able to copy plots and paste them
into either Word docs or AppleWorks docs. i can't seem to do that.
I do not know. However, try the "print" Octave command. After having
displayed a plot in the gnuplot window, you can use the print command to
save the plot to a .png or .ps file or whatever you like.
c***@gmail.com
2009-02-02 16:41:28 UTC
Permalink
Post by Francesco Potortì
 now i know that .bash_profile is a UNIX script
that runs when i launch Terminal (and i think that happens
automatically when Octave is launched), and i know what "if" and "fi"
are, but what is this DISPLAY system variable?  what does
   if [ -z ${DISPLAY} ]
   then
     export DISPLAY=:0.0
   fi
do and why does that make the difference between Octave plotting via
gnuplot via X11 and this not happening?  
I do not use a Mac, but: the DISPLAY shell variable (bash is a shell)
indicates that the X server is running and where it is.  The ":0.0"
value means that it is running on the same machine in the default
place.  The code lines that you wrote mean that, if the DISPLAY variable
is not already set, it is set to ":0.0".
It tells x11 enabled programs where to send its graphics.
(not necessary that the server is running).

":0.0" is the first screen of the first display of the local server
running on your machine.
Only if the DISPLAY is not already set does it select the local
machine.

This will always be true unless you login in remotely.
In which case, you do not want to overwrite the remote machine DISPLAY
value with the local machine.

You may find the following links helpful.
http://developer.apple.com/Darwin/runningX11.html
http://tldp.org/LDP/intro-linux/html/sect_07_03.html#sect_07_03_03

As a side note,
a) I believe the xterm X11.app starts by default sets DISPLAY for you.
I've editing my xinitrc file to not start xterm (I find it clumsy),
instead I run everything from Terminal.app and set DISPLAY
in .bash_profile in the way I've shared with you.

b) I believe the octave/gnuplot version you are using is "wrapped" by
platypus. It also may set DISPLAY for you.
http://www.sveinbjorn.org/platypus.
Post by Francesco Potortì
over the original .bash_profile.  do you know with a freshly installed
OS10.4.xx system and Developer folder (Xcode Tools 2.2.1), did
the .bash_profile file exist.  if so, was there a default content to
the file?  
I don't believe there is a default user .bash_profile on the Mac.
Post by Francesco Potortì
one more question:  how can i copy the graphic from the X11 window
with the plot in it?  i want to be able to copy plots and paste them
into either Word docs or AppleWorks docs.  i can't seem to do that.
I generally use the postscript terminal (set term postscript) when I
want to save plots.
Preview.app can open them and save to other file formats.
When using the postscript terminal, you will need to set the output to
a file (set output [filename]).

Another option is Grab.app.
robert bristow-johnson
2009-02-05 20:41:04 UTC
Permalink
Post by c***@gmail.com
Post by Francesco Potortì
 now i know that .bash_profile is a UNIX script
that runs when i launch Terminal (and i think that happens
automatically when Octave is launched), and i know what "if" and "fi"
are, but what is this DISPLAY system variable?  what does
   if [ -z ${DISPLAY} ]
   then
     export DISPLAY=:0.0
   fi
do and why does that make the difference between Octave plotting via
gnuplot via X11 and this not happening?  
I do not use a Mac, but: the DISPLAY shell variable (bash is a shell)
indicates that the X server is running and where it is.  The ":0.0"
value means that it is running on the same machine in the default
place.  The code lines that you wrote mean that, if the DISPLAY variable
is not already set, it is set to ":0.0".
so, essentially, this helps gnuplot find X11 to send to it graphics
instructions? where did these instructions go before? into the bit
bucket?
Post by c***@gmail.com
It tells x11 enabled programs where to send its graphics.
(not necessary that the server is running).
what server?
Post by c***@gmail.com
":0.0" is the first screen of the first display of the local server
running on your machine.
Only if the DISPLAY is not already set does it select the local
machine.
it seems to me that this should be the default setting. too bad it
was necessary to explicitly set this.
Post by c***@gmail.com
This will always be true unless you login in remotely.
In which case, you do not want to overwrite the remote machine DISPLAY
value with the local machine.
login in remotely to a personal computer (of which a Mac is) seems
esoteric to me.
Post by c***@gmail.com
You may find the following links helpful.
http://developer.apple.com/Darwin/runningX11.html
http://tldp.org/LDP/intro-linux/html/sect_07_03.html#sect_07_03_03
As a side note,
a) I believe the xterm X11.app starts by default sets DISPLAY for you.
well, it didn't set it to what i needed to view, because before i even
posted for this help, that's what i did (i think). it wasn't until
that .bash_profile code was added that i could get this to draw at
all.
Post by c***@gmail.com
I've editing my xinitrc file to not start xterm (I find it clumsy),
instead I run everything from Terminal.app and set DISPLAY
in .bash_profile in the way I've shared with you.
b) I believe the octave/gnuplot version you are using is "wrapped" by
platypus.  It also may set DISPLAY for you.http://www.sveinbjorn.org/platypus.
Post by Francesco Potortì
over the original .bash_profile.  do you know with a freshly installed
OS10.4.xx system and Developer folder (Xcode Tools 2.2.1), did
the .bash_profile file exist.  if so, was there a default content to
the file?  
I don't believe there is a default user .bash_profile on the Mac.
that's good to know.
Post by c***@gmail.com
Post by Francesco Potortì
one more question:  how can i copy the graphic from the X11 window
with the plot in it?  i want to be able to copy plots and paste them
into either Word docs or AppleWorks docs.  i can't seem to do that.
I generally use the postscript terminal (set term postscript) when I
want to save plots.
Preview.app can open them and save to other file formats.
When using the postscript terminal, you will need to set the output to
a file (set output [filename]).
Another option is Grab.app.
my preference would be to use simple Mac program. this Grab (i didn't
know of it before) looks like the old Shift-Command-3 we used to do on
Macs. Grab says it saves in TIFF, but can export to JPEG and PICT.
PICT would be fine with me if it's has the "vector graphics" content,
but i'm afraid that data is lost when the window is TIFFed by Grab.

thanks ccdr... for your help. i have some reading to do, and
eventually i'll have more questions (when i start doing serious
programming).

r b-j
Randy Yates
2009-02-06 15:50:17 UTC
Permalink
Hey Robert!

Glad to see you're taking the plunge to octave. Great!
Post by robert bristow-johnson
Post by c***@gmail.com
Post by Francesco Potortì
 now i know that .bash_profile is a UNIX script
that runs when i launch Terminal (and i think that happens
automatically when Octave is launched), and i know what "if" and "fi"
are, but what is this DISPLAY system variable?  what does
   if [ -z ${DISPLAY} ]
   then
     export DISPLAY=:0.0
   fi
do and why does that make the difference between Octave plotting via
gnuplot via X11 and this not happening?  
I do not use a Mac, but: the DISPLAY shell variable (bash is a shell)
indicates that the X server is running and where it is.  The ":0.0"
value means that it is running on the same machine in the default
place.  The code lines that you wrote mean that, if the DISPLAY variable
is not already set, it is set to ":0.0".
so, essentially, this helps gnuplot find X11 to send to it graphics
instructions? where did these instructions go before? into the bit
bucket?
Post by c***@gmail.com
It tells x11 enabled programs where to send its graphics.
(not necessary that the server is running).
what server?
The X11 display server.
Post by robert bristow-johnson
Post by c***@gmail.com
":0.0" is the first screen of the first display of the local server
running on your machine.
Only if the DISPLAY is not already set does it select the local
machine.
it seems to me that this should be the default setting. too bad it
was necessary to explicitly set this.
Now caveat because I have no idea how the mac operates, but I do
know a little about linux and X11.

The X11 system allows an application (e.g., octave, xterm, firefox,
etc.) and the user interface for that application (display, keyboard,
and mouse, primarily) to be relatively independent. It uses a
client/server model in which the server "serves" the display resources
and the "client" utilizes those resources.

(You may want to read this:

http://en.wikipedia.org/wiki/X_Window_System
)

For example, that when my college utilizes a $100,000 CAD program like
cadence, I don't have to be at the campus to use it. I can log into a
computer at the college (from home, via ssh, but that's another lesson),
run the application on the college's computer system, but be sitting at
home and have the display and keyboard "served" from my X11 display
server at home. This is VERY good thing, especially when you live 20
miles from the university.

So when an X11 client application starts, it must know which X11 display
server to connect to. There are two common methods of specifying this to
the application:

1. via the DISPLAY environment variable (this is the method your
.bash_profile script sets up)

2. via a command line option given when you run the application,
usually "-display [mycomputer]:mydisplay.mysubdisplay. (subdisplay?)
If you leave off [mycomputer] it assumes it's the one you're on.

From what I can tell, your x11.app is an X11 display server for the mac,
and it has to be running before you run any X11 client application
(anywhere, whether on your own machine or otherwise) that you want to
display on your machine.

Why don't you just set it unconditionally in the .bash_profile? Well,
what if your session was initiated from another computer? It would
already be set then to the remote computer and you wouldn't want
to overwrite it.
Post by robert bristow-johnson
Post by c***@gmail.com
This will always be true unless you login in remotely.
In which case, you do not want to overwrite the remote machine DISPLAY
value with the local machine.
login in remotely to a personal computer (of which a Mac is) seems
esoteric to me.
Then you haven't learned the power of X11 (and other utilities like
ssh and scp) and remote accessibility! I do it quite frequently.
Post by robert bristow-johnson
Post by c***@gmail.com
You may find the following links helpful.
http://developer.apple.com/Darwin/runningX11.html
http://tldp.org/LDP/intro-linux/html/sect_07_03.html#sect_07_03_03
As a side note,
a) I believe the xterm X11.app starts by default sets DISPLAY for you.
well, it didn't set it to what i needed to view, because before i even
posted for this help, that's what i did (i think). it wasn't until
that .bash_profile code was added that i could get this to draw at
all.
Post by c***@gmail.com
I've editing my xinitrc file to not start xterm (I find it clumsy),
instead I run everything from Terminal.app and set DISPLAY
in .bash_profile in the way I've shared with you.
b) I believe the octave/gnuplot version you are using is "wrapped" by
platypus.  It also may set DISPLAY for you.http://www.sveinbjorn.org/platypus.
Post by Francesco Potortì
over the original .bash_profile.  do you know with a freshly installed
OS10.4.xx system and Developer folder (Xcode Tools 2.2.1), did
the .bash_profile file exist.  if so, was there a default content to
the file?  
I don't believe there is a default user .bash_profile on the Mac.
that's good to know.
Post by c***@gmail.com
Post by Francesco Potortì
one more question:  how can i copy the graphic from the X11 window
with the plot in it?  i want to be able to copy plots and paste them
into either Word docs or AppleWorks docs.  i can't seem to do that.
I generally use the postscript terminal (set term postscript) when I
want to save plots.
Preview.app can open them and save to other file formats.
When using the postscript terminal, you will need to set the output to
a file (set output [filename]).
Another option is Grab.app.
my preference would be to use simple Mac program. this Grab (i didn't
know of it before) looks like the old Shift-Command-3 we used to do on
Macs. Grab says it saves in TIFF, but can export to JPEG and PICT.
PICT would be fine with me if it's has the "vector graphics" content,
but i'm afraid that data is lost when the window is TIFFed by Grab.
thanks ccdr... for your help. i have some reading to do, and
eventually i'll have more questions (when i start doing serious
programming).
As someone else already suggested, check out octave's "print" command.
It's much better than a screen grab because you can save the plot as
vector graphics (e.g., eps).

Good luck, my friend.
--
% Randy Yates % "She tells me that she likes me very much,
%% Fuquay-Varina, NC % but when I try to touch, she makes it
%%% 919-577-9882 % all too clear."
%%%% <***@ieee.org> % 'Yours Truly, 2095', *Time*, ELO
http://www.digitalsignallabs.com
e***@enadav.com
2012-09-30 22:13:33 UTC
Permalink
I did the same thing this guy did:
http://ask.wireshark.org/questions/9711/osx-libcairo2dylib-claims-libfreetype6dylib-provides-an-older-package-than-it-does

And it worked
Post by robert bristow-johnson
hi,
i've used Octave before on a Linux machine and am pretty well versed
with MATLAB. i downloaded all that i thought i was required to to get
System Version: Mac OS X 10.4.11 (8S165)
Kernel Version: Darwin 8.11.0
___________________________________
Last login: Tue Jan 27 16:10:18 on ttyp1
Welcome to Darwin!
robert-s-powerbook-g4-15:~ robert$ exec '/Applications/Octave.app/
Contents/Resources/bin/octave'
GNU Octave, version 3.0.2
Copyright (C) 2008 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.
Octave was configured for "powerpc-apple-darwin7.9.1".
Additional information about Octave is available at http://www.octave.org.
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html
http://www.octave.org/bugs.html to learn how to write a helpful
report).
For information about changes from previous versions, type `news'.
octave-3.0.2:1> x = linspace(0,1,4097);
octave-3.0.2:2> y = x.^2;
octave-3.0.2:3> plot(x,y);
octave-3.0.2:4>
___________________________________
before i started up Octave, i started up gnuplot, but i typed in no
___________________________________
Last login: Tue Jan 27 15:38:10 on ttyp1
exec '/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot'
Welcome to Darwin!
robert-s-powerbook-g4-15:~ robert$ exec '/Applications/Gnuplot.app/
Contents/Resources/bin/gnuplot'
G N U P L O T
Version 4.2 patchlevel 3
last modified Mar 2008
System: Darwin 8.11.0
Copyright (C) 1986 - 1993, 1998, 2004, 2007, 2008
Thomas Williams, Colin Kelley and many others
Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from http://www.gnuplot.info/faq/
Send bug reports and suggestions to <http://sourceforge.net/
projects/gnuplot>
Terminal type set to 'aqua'
gnuplot>
____________________________________
it appears that i *do* get these Octave arrays, "x" and "y", and the
call to plot() came back with no diagnostics, but i got no window with
any plot in it. what more must i do to get this to work? are there
any Mac Octave users out there that can help me?
thanks for any help. feel free to ask me about any DSP questions
(that's something i'm pretty good at, but i am no good at getting
sparsely documented software to work) in exchange.
r b-j
Loading...