Site original : bfontaine.net
When plotting with gnuplot-py
on OSX, I got an annoying warning
saying that terminal aqua
is unknown or ambiguous
, even when I use a
different terminal (e.g. postscript
). This terminal doesn’t exist on my
Gnuplot installation (4.6.3). In fact, gnuplot-py
uses slightly
different files depending on your platform. OSX’s one is exactly the same as
other UNIX-flavored OSes but its default terminal is aqua
. There are two ways
to fix the warning, a hacky one I used before this blog post, and a clean one I
discovered while writting this post. Hope this help!
Since OSX’s Gnuplot file is the same as Linux’s one apart from its default
term, we just need to tell gnuplot-py
we’re on Linux:
1 2 3 4 5 6 7 8 |
|
It temporarily changes sys.platform
value, which gnuplot-py
is relying on,
to "linux"
, import Gnuplot and then restore it back to its previous value
("darwin"
).
In fact there’s a much cleaner way to fix the warning. The default terminal is
stored in GnuplotOpts.default_term
, so we just need to change
it to another value to fix the warning:
1 2 |
|
It’s cleaner than the hacky way because:
default_term
to
'x11'
. We don’t even need to add a comment.gnuplot-py
interface change in the
future, this piece of code won’t break compatibility while the hacky way
will prevent our code to use the new interface.