In [6]:
import numpy as np
from bokeh.io import output_notebook, show
from bokeh.models import Legend, ColumnDataSource
from bokeh.plotting import figure
from bokeh.resources import INLINE
output_notebook(resources=INLINE)
In [62]:
x = np.linspace(-2*np.pi, 2*np.pi, 100)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))
plot_opts = {
'plot_width': 400,
'plot_height': 200,
'tools': 'previewsave',
'min_border': 2
}
In [69]:
def make_plot(min_border_left=0, min_border_bottom=0):
p = figure(min_border_left=min_border_left, min_border_bottom=min_border_bottom, **plot_opts)
line = p.line(x="x", y="y", source=source)
legend = Legend(location=(50, 75), legends=[("x: 50px, y: 75px", [line])])
p.add_layout(legend)
return p
In [70]:
show(make_plot())
Out[70]:
In [72]:
p = make_plot()
p.xaxis.axis_label = "x axis"
p.xaxis.axis_label_text_font_size = '16pt'
p.yaxis.axis_label = "y axis"
p.yaxis.axis_label_text_font_size = '16pt'
show(p)
Out[72]:
In [ ]: