There are different plotting backends supported:
You create plotting object and can show it using the following functions:
mpld3 library allows you plot matplotlib in intarecative regime.
%pylab inline
Populating the interactive namespace from numpy and matplotlib
import mpld3
from rep.plotting import FunctionsPlot
n_points = 30
first_func = (numpy.linspace(0, 10, n_points), numpy.random.random(n_points))
second_func = (numpy.linspace(-10, 0, n_points), numpy.random.random(n_points))
obj = FunctionsPlot({'first': first_func, 'second': second_func})
obj.plot()
obj.plot(xlim=(-5, 5), ylim=(0.2, 0.8), title='example', xlabel='x', ylabel='y', fontsize=15)
mpld3.display()
obj.plot_plotly("functions")
obj.plot_bokeh(figsize=(15, 10), xlabel='x', title='Example', ylim=(0, 0.5))
obj.plot_tmva(new_plot=True, figsize=(6, 6), title='TMVA example')
obj1 = FunctionsPlot({'first': first_func})
obj2 = FunctionsPlot({'second': second_func})
# put new_plot to se separate figures for lines in matplotlib
obj1.plot(new_plot=True)
obj2.plot(new_plot=True, xlabel='x')
obj1.plot()
obj2.plot(xlabel='x', show_legend=False)
obj1.plot()
obj2.plot(xlabel='x', show_legend=False)
mpld3.display()
obj1.plot_plotly('one', title='plotly', xlabel='x', ylabel='points')
obj2.plot_plotly('two', title='plotly', xlabel='x', ylabel='points', xlim=(-8, -2), ylim=(0.2, 0.8), fontsize=13,
show_legend=False)
obj1.plot_bokeh()
obj2.plot_bokeh(title='bokeh', xlabel='x', ylabel='points', xlim=(-8, -2), ylim=(0.2, 0.8), fontsize=13,
show_legend=False)
from rep.plotting import GridPlot, HStackPlot, VStackPlot
grid = GridPlot(2, obj1, obj2, obj1)
# parameters doesn't work here, set them for each plot in grid
grid.plot(title='grid', xlabel='x', ylim=(0.2, 0.8))
obj1.xlabel = 'x'
obj2.xlabel = 'y'
obj1.figsize = (8, 6)
obj2.figsize = (4, 3)
grid = GridPlot(2, obj1, obj2, obj1)
# Only inner parameters of plot is used in grid, so grid ignores all parameters in plot(...)
grid.plot(xlabel='try', ylim=(0.2, 0.8))
# Only show_legend and fontsize can be set using parameters
grid.plot(show_legend=False, fontsize=30)
mpld3.display()
grid.plot_plotly("grid")
grid.plot_bokeh()
hstack = HStackPlot(obj1, obj2, obj1)
hstack.plot(title='stack', xlabel='x', ylim=(0.2, 0.8))
hstack.plot(show_legend=False, fontsize=20)
mpld3.display()
hstack.plot_plotly("hstack")
hstack.plot_bokeh()
vstack = VStackPlot(obj1, obj2, obj1)
vstack.plot(new_plot=True, figsize=(6, 12), title='stack', xlabel='x', ylim=(0.2, 0.8))
vstack.plot(new_plot=True, figsize=(6, 12), show_legend=False, fontsize=10)
mpld3.display()
vstack.plot_plotly("vstack", figsize=(8, 13))
vstack.plot_bokeh(figsize=(8, 13))
from rep.plotting import ColorMap
matrix = numpy.ndarray(shape=(3, 3), buffer=numpy.random.random(size=9))
cm = ColorMap(matrix, labels=['feature {}'.format(index) for index in range(3)])
cm.plot(show_legend=False)
cm.plot()
mpld3.display()
/Users/antares/.virtualenvs/rep_open/lib/python2.7/site-packages/matplotlib/axes.py:4747: UserWarning: No labeled objects found. Use label='...' kwarg on individual plots.
cm.plot_plotly('colormap', figsize=(6, 6))
cm.plot_bokeh()
from rep.plotting import BarPlot
data = {'normal': (random.normal(0, 0.5, 100), ones(100), 'filled'),
'gamma': (random.gamma(1.0, 2.0, 100), ones(100), '')}
bar = BarPlot(data)
bar.plot()
bar.plot()
mpld3.display()
bar.plot_plotly('bar')
from rep.plotting import BarComparePlot
data = {'normal': {'one': 23, 'two': 34, 'three': 45},
'gamma': {'one': 11, 'two': 23, 'three': 33}}
bar_c = BarComparePlot(data, sortby='normal')
bar_c.plot()
bar_c.plot()
mpld3.display()
bar_c.plot_plotly('bar_c')
bar_c.plot_bokeh()
from rep.plotting import ErrorPlot
err = ErrorPlot({'uniform': (numpy.random.random(size=3), numpy.random.random(size=3),
numpy.random.random(size=3), numpy.random.random(size=3))})
err.plot()
err.plot()
mpld3.display()
/Users/antares/.virtualenvs/rep_open/lib/python2.7/site-packages/mpld3/mplexporter/exporter.py:171: UserWarning: Legend element <matplotlib.collections.LineCollection object at 0x10c4a1350> not impemented /Users/antares/.virtualenvs/rep_open/lib/python2.7/site-packages/mpld3/mplexporter/exporter.py:171: UserWarning: Legend element <matplotlib.collections.LineCollection object at 0x10c4a1fd0> not impemented
err.plot_plotly('err')
from rep.plotting import ScatterPlot
x_val = random.uniform(0.0, 1000.0, 100)
y_val = random.uniform(0.0, 1000.0, 100)
sp = ScatterPlot({'simple': (x_val, y_val),
'second': (y_val, x_val)},
alpha=1, size=30)
sp.plot()
sp.plot()
mpld3.display()
/Users/antares/.virtualenvs/rep_open/lib/python2.7/site-packages/mpld3/mplexporter/exporter.py:171: UserWarning: Legend element <matplotlib.collections.PathCollection object at 0x10b90c7d0> not impemented /Users/antares/.virtualenvs/rep_open/lib/python2.7/site-packages/mpld3/mplexporter/exporter.py:171: UserWarning: Legend element <matplotlib.collections.PathCollection object at 0x10b90c9d0> not impemented
sp.plot_plotly('scatter')
sp.plot_bokeh()
from rep.plotting import Function2D_Plot
def func(x, y):
return numpy.sin(x + y*y)
func_plot = Function2D_Plot(func, xlim=(0, 5), ylim=(0, 5), xsteps=100, ysteps=100)
func_plot.plot()
func_plot.plot()
mpld3.display()
func_plot.plot_plotly("function2d")