Python plotting APIs
Project description
Plotter
A sane plotting API. Currently it only supports matplotlib as the backend, but other backends can be plugged.
Source
https://bitbucket.org/avilay/plotter/src/master/
Installation
pip install avilabs-plotter
Quick Start
import plotter as pltr
pltr.set_backend(pltr.MatplotlibBackend)
nodes = ['master', 'worker1', 'worker2']
cpus = [0.1, 0.6, 0.4]
cpusbar = pltr.VerticalBar(categories=nodes, values=cpus)
pltr.show_plot('CPU Performance', cpusbar)
Output:
Plot Styles
Plotter can plot a number of different plot styles.
Samples
Categorical Plots
When the x-axis is composed of labels and the y-axis are numbers.
- Horizontal Bar
- Line
- Vertical Bar
Numeric Plots
When both the x-axis and y-axis are numbers.
- Graph
- Scatter
Images
- Grayscale Image
- RGB Image
Concepts
Frame --> * Chart --> * Plot --> * Axis
A Plot
is composed of Axis
objects. A Chart
can have multiple Plot
s in it, provided all their Axis
are compatible. A Frame
can have multiple Chart
s.
Detailed Usage
import numpy as np
from plotter import Axis, Frame, Graph, MatplotlibBackend, set_backend, Font, Color
set_backend(MatplotlibBackend)
frame = Frame(height_px=600, width_px=10000)
frame.layout(nrows=1, ncols=2)
# Trig chart
chart = frame.create_chart()
chart.title = 'Trig Chart'
chart.x_axis = Axis(label='Radians', font=Font(size=14, color=Color(red=255, blue=126, green=0)))
cosx = Graph((-np.pi, np.pi), np.cos, legend='cos(x)')
chart.add(cosx)
sinx = Graph((-np.pi, np.pi), np.sin, legend='sin(x)')
chart.add(sinx)
# Geometry chart
chart = frame.create_chart()
chart.grid = True
chart.origin = (0, 0)
line = Graph((-10, 10), lambda x: 2*x)
chart.add(line)
chart.x_axis = Axis(label='x')
chart.y_axis = Axis(label='y', limits=(-25, 25))
frame.show()
Output:
See the examples directory for more usage.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
avilabs-plotter-0.3.3.tar.gz
(7.3 kB
view hashes)