Python 如何更改散景图的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21980662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:01:02  来源:igfitidea点击:

How to change size of bokeh figure

pythonplotbokeh

提问by Philliproso

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 herewhich has subplots and sets height and width in the creation of a Plot object.

我已经阅读了大部分关于散景的文档和许多示例。它们都包含默认的方形窗口。我见过的唯一一个稍微不同的例子是这里有子图并在创建 Plot 对象时设置高度和宽度。

采纳答案by Peter Wang

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 heightand widthattributes. If you are building up a Plotobject 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.

如果您已经创建了绘图,那么您可以使用该bokeh.plotting.curplot()函数返回“当前”绘图,然后设置其heightwidth属性。如果您正在Plot使用较低级别的接口(例如 中的示例)构建对象bokeh/examples/glyph/,那么您也可以直接在绘图对象或Plot()构造函数中设置这些属性。

Alternatively, if you are using any of the glyph generation functions in bokeh.plotting, you can pass the plot_widthand plot_heightkeyword arguments, e.g.:

或者,如果您在 中使用任何字形生成函数bokeh.plotting,您可以传递plot_widthplot_height关键字参数,例如:

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

回答by Philliproso

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

很抱歉回答我自己的问题,这实际上很容易。

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

回答by Paul

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.

您可以将 plot_width/plot_height 命令添加到图形命令本身。请注意,您还可以通过工具关键字 var 中的 resize 将调整大小工具添加到工具集中,这很有帮助。

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