如何获取散景以根据缩放比例缩放散点图大小 [英] How to get Bokeh to scale scatter plot size according to zoom
问题描述
我团队中的一些人,包括我自己,都发现在散景散点图中,例如使用 circle
方法,对于图上数据的初始自动缩放拟合,相当令人迷惑我们可以使用例如 plot.circle(x,y,size = 3)
Some of the folks on my team, including myself, find it pretty disorienting that in a Bokeh scatter plot, say using the circle
method, that for an initial autoscale fit of the data on the figure we can dial in a reasonable size for our data, using for example something like plot.circle( x , y , size=3 )
但是,当我们交互式地缩放数据时,显示的字形大小对于缩放是不变的.有没有办法让它们与我们拨入的缩放比例成比例?与矢量图形交互类似的东西(例如svg).如果记忆对我有帮助,则matlab图形和matplotlib图形应保持缩放比例行为.为了演示这种行为,我们考虑第一张图片和我放大到第二张图片上的红色框.
However when we interactively zoom into our data the glyph sizes as displayed are invariant to the zoom. Is there a way to have them scale proportionally to the zoom we've dialed into? Something akin to an vector graphics interaction (eg svg). If memory serves me right matlab figures and matplotlib figures should maintain zoom proportionality behavior. To demonstrate the behavior we're seeing consider the first image and the red box I approximately zoom into on the second image.
作为使用Powerpoint的快速演示来说明所需行为的种类...
Just as a quick demo using Powerpoint to illustrate the sort of desired behavior...
推荐答案
对于圈子,设置 radius
kwarg而不是 size
值.(其他字形类型也有类似的字形特定值).
For circles, set the radius
kwarg instead of the size
value. (There similar, glyph-specific values for the other glyph-types).
即:
plot.circle(x=[1,2,3], y=[1,2,3], radius=0.5)
size
总是在屏幕坐标(像素)中呈现,但是 radius
及其相关属性是在数据坐标中计算的,并且应该随着缩放而变化.
size
is always rendered in screen coordinates (pixels), but radius
and the related properties are computed in data coordinates and should change in magnitude with zooming.
这篇关于如何获取散景以根据缩放比例缩放散点图大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!