krishnab
krishnab

Reputation: 10060

Can I set the bokeh figure size across an entire jupyter notebook

Using Matplotlib with the Jupyter notebook, I could set the figure size all matplotlib figures across the notebook with the notebook instruction:

pylab.rcParams['figure.figsize'] = (14, 14)

Is there a similar instruction in bokeh? I have looked and only found references to the ability to set figure size in the figure function itself:

p = bokeh.plotting.figure(x, y,plot_width=400, plot_height=400)

But that means I have to program the size for each and every plot, etc. I was just wondering if this functionality exists in bokeh currently.

Upvotes: 4

Views: 3872

Answers (1)

krishnab
krishnab

Reputation: 10060

There does appear to be a built-in way to set the default chart size.

from bokeh.charts import defaults

defaults.width = 450
defaults.height = 350

This should set the standard for an entire notebook.

UPDATE

The bokeh.charts subpackage has been removed in the current version of bokeh 0.12.10. This subpackage was supposed to move over to another bkcharts package but apparently bkcharts is no longer maintained. If you use the code above, you will get an error if the bokeh version is greater than 0.12.9.

The alternative is to just create a global variable named:

width = 450
height = 350

Then you can just reference these values in your plots. So

from bokeh.plotting import figure
p = figure(plot_width=width, plot_height=height)

You will of course have to include this instruction for every plot in your notebook.

Upvotes: 4

Related Questions