Welcome to modesolverpy’s documentation!¶
Contents:
Introduction¶
The documentation for gnuplotpy. Gnuplotpy facilitates communicating to Gnuplot from Python, namely passing Python variables and data to Gnuplot scripts.
Examples¶
Two example scripts.
Example 1¶
Code¶
import numpy as np
import gnuplotpy as gp
amplitude = 3.
x = np.linspace(0., 2*3.14, 100)
y = amplitude*np.sin(x)
args = {
'the_title': 'Example 1',
'amp': amplitude,
'x_max': x[-1],
'filename': 'example1.png'
}
data = [x, y]
gp.gnuplot('example1.gpi', args, data)
set datafile separator ','
set term pngcairo size 20cm,20cm
set out filename
unset key
set grid
set border lw 1.5
set title the_title
set xrange [x_max-1.1*x_max:x_max*1.1]
set yrange [-1.1*amp:1.1*amp]
plot data u 1:2 w lp pt 7 ps 0.5 lw 2
set out
Output¶

Example 2¶
Code¶
import numpy as np
import gnuplotpy as gp
x = np.linspace(-5, 5, 100)
y = x**2
gp.gnuplot_2d(x, y, 'example2a.png', 'Example 2a', 'x', 'x^2')
z = np.linspace(0., 2.*np.pi, 10000)
z = z.reshape(100, 100)
z = np.round(np.sin(z), 1)
gp.gnuplot_3d_matrix(z, 'example2b.png', 'Example 2b', 'x', 'y')
API¶
Functions¶
gnuplot (script_name[, args_dict, data, silent]) |
Call a Gnuplot script, passing it arguments and datasets. |
gnuplot_2d (x, y, filename[, title, x_label, …]) |
Function to produce a general 2D plot. |
gnuplot_3d (x, y, z, filename[, title, …]) |
Function to produce a general 3D plot. |
gnuplot_3d_matrix (z_matrix, filename[, …]) |
Function to produce a general 3D plot from a 2D matrix. |
trim_pad_image (filename[, padding]) |
Trims and pads an image. |