如何配置散景图以具有响应宽度和固定高度
How to configure bokeh plot to have responsive width and fixed height
我使用通过组件功能嵌入的散景。
实际上我使用:
plot.sizing_mode = "scale_width"
根据宽度缩放并保持纵横比。但我希望有一个响应宽度但一个固定或最大高度。这怎么可能实现?
有stretch_both
和scale_both
选项。
How the item being displayed should size itself. Possible values are "fixed", "scale_width", "scale_height", "scale_both", and "stretch_both".
"stretch_both" elements are completely responsive (independently in width and height) and will resize to occupy all available space, even if this changes the aspect ratio of the element. This is sometimes called outside-in, and is a typical behavior for desktop applications.
...
"scale_both" elements will responsively resize to for both the width and height available, while maintaining the original aspect ratio.
https://docs.bokeh.org/en/latest/docs/user_guide/layout.html
您手动设置两个图的高度和宽度,并为layout/gridplot设置sizing_mode='scale_width',如下(这将设置固定的宽高比并允许你按宽度缩放):
plot1 = figure(width=1000, height=300)
# add lines here
plot2 = figure(width=1000, height=100)
# add lines here
plots = gridplot([[plot1], [plot2]], sizing_mode='scale_width')
show(plots)
我使用通过组件功能嵌入的散景。
实际上我使用:
plot.sizing_mode = "scale_width"
根据宽度缩放并保持纵横比。但我希望有一个响应宽度但一个固定或最大高度。这怎么可能实现?
有stretch_both
和scale_both
选项。
How the item being displayed should size itself. Possible values are "fixed", "scale_width", "scale_height", "scale_both", and "stretch_both".
"stretch_both" elements are completely responsive (independently in width and height) and will resize to occupy all available space, even if this changes the aspect ratio of the element. This is sometimes called outside-in, and is a typical behavior for desktop applications.
...
"scale_both" elements will responsively resize to for both the width and height available, while maintaining the original aspect ratio.
https://docs.bokeh.org/en/latest/docs/user_guide/layout.html
您手动设置两个图的高度和宽度,并为layout/gridplot设置sizing_mode='scale_width',如下(这将设置固定的宽高比并允许你按宽度缩放):
plot1 = figure(width=1000, height=300)
# add lines here
plot2 = figure(width=1000, height=100)
# add lines here
plots = gridplot([[plot1], [plot2]], sizing_mode='scale_width')
show(plots)