Philliproso
Philliproso

Reputation: 1276

How to change size of bokeh figure

I have read most of the documentation on bokeh and many of the examples. All of them contain the default square window. The only example I have seen that is the slightly different is here which has subplots and sets height and width in the creation of a Plot object.

Upvotes: 42

Views: 58700

Answers (5)

flor.debois
flor.debois

Reputation: 63

If you have a figure with name p you can simply do the following.

p.plot_height=400
p.plot_width=800

(Bokeh version 2.4.3)

Upvotes: 3

mufassir
mufassir

Reputation: 562

In version 2.4.2:

An argument named figsize is there to set the size of the plot.

e.g.

count_df.plot_bokeh(
    title="Replenishment Count",
    xlabel="Date",
    ylabel="Number of Replenishment",
    figsize=(1000, 800),
)

NOTE: Only applicable on plot_bokeh method in dataframes.

Upvotes: 0

Philliproso
Philliproso

Reputation: 1276

Sorry to answer my own question, this was actually easy.

bokeh.plotting.curplot().plot_height=400
bokeh.plotting.curplot().plot_width=800

Upvotes: 8

Paul
Paul

Reputation: 7325

You can add the plot_width/plot_height commands to the figure command itself. Notice you can also add the resize tool to the set of tools via resize in the tools keyword var, which can be helpful.

bokeh.plotting.figure(x_axis_type = "datetime",    
  tools="pan,wheel_zoom,box_zoom,reset,resize,previewsave",plot_width=1000, 
  name="myplot")

Upvotes: 14

Peter Wang
Peter Wang

Reputation: 1638

If you've already created the plot, then you can use the bokeh.plotting.curplot() function to return the "current" plot, and then set its height and width attributes. If you are building up a Plot object using the lower-level interfaces (e.g. the examples in bokeh/examples/glyph/, then you can just set those attributes directly as well on the plot object or in the Plot() constructor.

Alternatively, if you are using any of the glyph generation functions in bokeh.plotting, you can pass the plot_width and plot_height keyword arguments, e.g.:

line(x,y, color="#0000FF", tools="pan,wheel_zoom,box_zoom,reset",
     name="line_example", plot_width=800, plot_height=300)

Upvotes: 42

Related Questions