自动将散景图拟合到屏幕上吗? [英] Automatically fit Bokeh plot to screen?

查看:56
本文介绍了自动将散景图拟合到屏幕上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以自动将散景图拟合到用于显示浏览器的屏幕上?现在,我正在手动设置绘图的宽度和高度.

Is there a simple way to automatically fit a Bokeh plot to the screen used to display your browser? Right now I'm setting the plot width and height manually.

注意:当我说合适时,我的意思是我希望该图填充可见屏幕的80%.

Note: when I say fit I mean that I want the plot to fill 80% of the visible screen.

推荐答案

在较新的bokeh版本中,是的,您可以轻松地做到这一点.

In more recent bokeh versions, yes you can do this (easily).

绘图和布局现在具有sizing_mode属性,默认情况下将其设置为fixed.其他值包括scale_widthscale_heightscale_both.

plots and layouts now have a sizing_mode property which by default is set to fixed. The other values include scale_width, scale_height, and scale_both.

import bokeh.plotting
import bokeh.layouts

fig1 = bokeh.plotting.figure()
fig1.sizing_mode = 'scale_width'

fig2 = bokeh.plotting.figure()
fig2.sizing_mode = 'scale_width'

column = bokeh.layouts.column([fig1, fig2])
column.sizing_mode = 'scale_width'

如上例所示,您的布局需要适当设置其sizing_mode属性,以扩展其子图.

As in the example above, your layout will need to have its sizing_mode attribute set appropriately to let its children plots expand.

使用以上示例,您的绘图将扩展到其容器的大小.由您决定合适的容器大小(使用CSS)以适合您的需求.

Using the above example your plot will expand to the size of its container. It's up to you to appropriately size the container (using CSS) to suit your needs.

请注意,图形/图形的width/height属性仍然很重要:它们确定bokeh布局缩放的比例.

Note that the width/height property of your figures/plots still matter: they determine the ratio at which the bokeh layout scales.

这篇关于自动将散景图拟合到屏幕上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆