Gnuplot – Show Two Data Series at Once In Different Colors in Surface Plot

The answer is simple:

In the Gnuplot terminal you just call “splot” with two or more comma seperated arguments as so:

gnuplot> set title "Problem 6.1 (a)"
gnuplot> set xlabel "x"
gnuplot> set ylabel "y"
gnuplot> splot 'c:\docume~1\gregory\locals~1\temp\tmpr8yu4s' notitle, 'c:\docume
~1\gregory\locals~1\temp\tmprewjaw' notitle, (-.7*y)+.5

And in Gnuplot.py my full working code to plot two series of data and also a plane to hopefully separate them looked like this:

#prob 3.4
from __future__ import division
from Numeric import *

# If the package has been installed correctly, this should work:
import Gnuplot, Gnuplot.funcutils

g = Gnuplot.Gnuplot(debug=1)
g.title('Problem 6.1 (a)')
g.xlabel('x')
g.ylabel('y')
coords1=[
(0,0,1),
(0,1,0),
(0,1,1),
(1,0,1),
(1,1,0),
(1,1,1)
]
coords2=[
(0,0,0),
(1,0,0),
]
g.splot(coords1,coords2,'(-.7*y)+.5')

And here’s the pretty result:
gnuplot.jpg

[tags]Gnuplot, Python, Linear Separability[/tags]

Comments are closed.