https://github.com/jtambasco/gnuplotpy
Basic Python interface to Gnuplot.
https://github.com/jtambasco/gnuplotpy
Last synced: about 1 month ago
JSON representation
Basic Python interface to Gnuplot.
- Host: GitHub
- URL: https://github.com/jtambasco/gnuplotpy
- Owner: jtambasco
- License: mit
- Created: 2016-12-25T15:31:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-08T02:41:14.000Z (about 6 years ago)
- Last Synced: 2025-03-30T21:51:14.465Z (2 months ago)
- Language: Python
- Size: 103 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gnuplotpy
Basic Python interface to Gnuplot.Documentation can be found [here](http://gnuplotpy.readthedocs.io/).
Works under Python 2 and Python 3.
## Installation
* pip: `pip3 install gnuplotpy` # or `pip2`
* Arch Linux: `yaourt -S python-gnuplotpy`### Dependencies
If installing using the [Arch Linux AUR package](https://aur.archlinux.org/packages/python-gnuplotpy/), dependencies will be automatically downloaded and installed, if not, one should ensure the following dependencies are installed:#### Python
* [setuptools](https://pypi.python.org/pypi/setuptools).
#### Other
* [Gnuplot](http://www.gnuplot.info/).
## Examples
### Passing Python variables to a Gnuplot script:#### Gnuplot script:
```gnuplot
set datafile separator ','
set term pngcairo size 20cm,20cm
set out filenameunset key
set grid
set border lw 1.5set 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
```#### Python script:
```python
import numpy as np
import gnuplotpy as gpamplitude = 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('test.gpi', args, data)
```
### Plotting simple 2D and 3D plots:
#### Python script
```python
import numpy as np
import gnuplotpy as gpx = 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')
```
### Output
![]()
## Contributions
If you add functionality, I'd be interested and would appreciate if you send me a pull request.