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.
In [1]:
%pylab inline
In [2]:
import mpld3
In [3]:
from rep.plotting import FunctionsPlot
In [4]:
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})
In [5]:
obj.plot(new_plot=True)
In [6]:
obj.plot(new_plot=True, xlim=(-5, 5), ylim=(0.2, 0.8), title='example', xlabel='x', ylabel='y', fontsize=15)
mpld3.display()
Out[6]:
In [7]:
obj.plot_plotly("functions")
Out[7]:
In [8]:
obj.plot_bokeh(figsize=(15, 10), xlabel='x', title='Example', ylim=(0, 0.5))
In [9]:
obj.plot_tmva(new_plot=True, figsize=(6, 6), title='TMVA example')
Out[9]:
In [10]:
obj1 = FunctionsPlot({'first': first_func})
obj2 = FunctionsPlot({'second': second_func})
In [11]:
# put new_plot to separate figures for lines in matplotlib
obj1.plot(new_plot=True)
obj2.plot(new_plot=True, xlabel='x')
In [12]:
obj1.plot(new_plot=True)
obj2.plot(new_plot=True, xlabel='x', show_legend=False)
In [13]:
obj1.plot(new_plot=True)
obj2.plot(new_plot=True, xlabel='x', show_legend=False)
mpld3.display()
Out[13]:
In [14]:
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)
Out[14]:
In [15]:
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)
In [16]:
from rep.plotting import GridPlot, HStackPlot, VStackPlot
grid = GridPlot(2, obj1, obj2, obj1)
In [17]:
# parameters doesn't work here, set them for each plot in grid
grid.plot(title='grid', xlabel='x', ylim=(0.2, 0.8))
In [18]:
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))
In [19]:
# Only show_legend and fontsize can be set using parameters
grid.plot(show_legend=False, fontsize=30)
mpld3.display()
Out[19]:
In [20]:
grid.plot_plotly("grid")
Out[20]:
In [21]:
grid.plot_bokeh()
In [22]:
hstack = HStackPlot(obj1, obj2, obj1)
In [23]:
hstack.plot(title='stack', xlabel='x', ylim=(0.2, 0.8))
In [24]:
hstack.plot(show_legend=False, fontsize=20)
mpld3.display()
Out[24]:
In [25]:
hstack.plot_plotly("hstack")
Out[25]:
In [26]:
hstack.plot_bokeh()
In [27]:
vstack = VStackPlot(obj1, obj2, obj1)
In [28]:
vstack.plot(new_plot=True, figsize=(6, 12), title='stack', xlabel='x', ylim=(0.2, 0.8))
In [29]:
vstack.plot(new_plot=True, figsize=(6, 12), show_legend=False, fontsize=10)
mpld3.display()
Out[29]:
In [30]:
vstack.plot_plotly("vstack", figsize=(8, 13))
Out[30]:
In [31]:
vstack.plot_bokeh(figsize=(8, 13))
In [32]:
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)])
In [33]:
cm.plot(show_legend=False)
In [34]:
cm.plot()
mpld3.display()
Out[34]:
In [35]:
cm.plot_plotly('colormap', figsize=(6, 6))
Out[35]:
In [36]:
cm.plot_bokeh()
In [37]:
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)
In [38]:
bar.plot()
In [39]:
bar.plot()
mpld3.display()
Out[39]:
In [40]:
bar.plot_plotly('bar')
Out[40]:
In [41]:
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')
In [42]:
bar_c.plot()
In [43]:
bar_c.plot()
mpld3.display()
Out[43]:
In [44]:
bar_c.plot_plotly('bar_c')
Out[44]:
In [45]:
bar_c.plot_bokeh()
In [46]:
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))}, size=5)
In [47]:
err.plot()
In [48]:
err.plot()
mpld3.display()
Out[48]:
In [49]:
err.plot_plotly('err')
Out[49]:
In [50]:
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)
In [51]:
sp.plot()
In [52]:
sp.plot()
mpld3.display()
Out[52]:
In [53]:
sp.plot_plotly('scatter')
Out[53]:
In [54]:
sp.plot_bokeh()
In [55]:
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, vmin=0.5, vmax=1)
In [56]:
func_plot.plot()
In [57]:
func_plot.plot()
mpld3.display()
Out[57]:
In [58]:
func_plot.plot_plotly("function2d")
Out[58]:
In [59]:
from rep.plotting import Histogram2D_Plot
hist2d_plot = Histogram2D_Plot([numpy.random.random(100), numpy.random.random(100)], bins=30,
range=[[0.1, 0.6], [0.2, 0.7]])
In [60]:
hist2d_plot
Out[60]:
In [61]:
hist2d_plot.plot_plotly("hist2d")
Out[61]:
In [62]:
%matplotlib notebook
In [63]:
hist2d_plot.plot(new_plot=True)