Everybody loves plots!

Visualizing of training result

There are different plotting backends supported:

  • matplotlib (default, de-facto standard plotting library),
  • plotly (proprietary package with interactive plots, information is kept on the server),
  • ROOT (the library used by CERN employer),
  • bokeh (open-source package with interactive plots)

You create plotting object and can show it using the following functions:

  • matplotlib plot()
  • plotly plot_plotly()
  • ROOT plot_tmva()
  • bokeh plot_bokeh()

mpld3 library allows you plot matplotlib in intarecative regime.


In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
import mpld3

FunctionsPlot


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})

matplotlib


In [5]:
obj.plot(new_plot=True)


matplotlib using mpld3 interactive plots


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]:

plotly interactive plots


In [7]:
obj.plot_plotly("functions")


Out[7]:

bokeh interactive plots


In [8]:
obj.plot_bokeh(figsize=(15, 10), xlabel='x', title='Example', ylim=(0, 0.5))


BokehJS successfully loaded.

tmva style


In [9]:
obj.plot_tmva(new_plot=True, figsize=(6, 6), title='TMVA example')


Out[9]:

separate two lines


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)


BokehJS successfully loaded.