GNU Plot Example
GNU Plot Example
Gnuplot (http://www.gnuplot.info)
numpy
Installation:
Using pip
Using conda
Upgrade:
Functions:
c(command)
pipe a command to gnuplot as if in gnuplot command promt
c('plot sin(x)')
s(data, filename=’tmp.dat’)
save arrays into file (filename = ‘tmp.dat’) easily read by Gnuplot
plot(data, filename=’tmp.dat’)
Plot some data. Saves data into filename (default = ‘tmp.dat’) and then sends plot
instructions to Gnuplot
plot([x,y])
figure(number=None, term=’x11’)
Create a new or update a figure
figure(1)
p('myfile.ps')
pdf('myfile.pdf')
Setup terminal
Default terminal is ‘x11’ unless defined otherwise i.e. for windows:
import PyGnuplot as gp
gp.default_term = 'wxt'
Examples:
1 Example code
import PyGnuplot as gp
import numpy as np
X = np.arange(10)
Y = np.sin(X/(2*np.pi))
Z = Y**2.0
gp.s([X,Y,Z])
gp.p('myfigure.ps')
2 Example file
python example.py