How to change size of bokeh figure
Solution 1
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)
Solution 2
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")
Solution 3
Sorry to answer my own question, this was actually easy.
bokeh.plotting.curplot().plot_height=400
bokeh.plotting.curplot().plot_width=800
Philliproso
Updated on August 15, 2020Comments
-
Philliproso over 3 years
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.
-
Mackie Messer almost 8 yearsJust FYI, in bokeh 0.12 i believe you can set this as a keyword in bokeh.plotting.figure() as mentioned below. However, the correct keywords are 'width' and 'height', not 'plot_width' and 'plot_height'. Moreover, I believe the value must be an integer, not a float. Since my figure is embedded, and I was tinkering on the server, this took me a while to figure. I could not find this information in their documentation of 'figure()', only an example. Hope it helps. To clarify by way of example: exampleFig = bokeh.plotting.figure(width=200, height=200)
-
mlk almost 7 yearsmodule 'bokeh.plotting' has no attribute 'curplot' I cant find anything about curplot() any help? thank you
-
mlk almost 7 yearsmodule 'bokeh.plotting' has no attribute 'curplot' I cant find anything about curplot() any help? thank you
-
Peter Wang almost 7 yearscurplot() has been deprecated for some time. You can see more information here: continuum.io/blog/bokeh-0.7#api-deprecations The API is more explicit now. Basically you keep track of plots (which is much better) you want to act on: p = figure(...); p.circle(...); p.plot_height=400; show(p)
-
Rutger Hofste almost 6 yearsis there a way to set the width to the width of a jupyter cell?
-
kbrose over 5 yearsThis raises
ValueError: unexpected tool name 'resize', similar tools are reset
on bokeh 1.0.1 -
Paul over 5 yearsLooks like the resize tool was deprecated then removed: github.com/bokeh/bokeh/issues/4944. In the .11 series it is found in the default tools : github.com/bokeh/bokeh/blob/0.11.1/bokeh/plotting/figure.py Subsequently removed by 1 series