在高级图表上设置 x 轴和 y 轴范围?
Setting x-axis and y-axis range on high-level charts?
下面的图表以及 Bokeh 文档中作为示例提供的许多高级图表都存在一个问题:它在图表的任一侧都造成了不必要的视觉迷惑 space x 轴和 y 轴。参见,例如,this example.
如果图表的角精确地切入坐标轴的边缘(因此我的区域的左下角位于图表的左下角和我的区域的右下角),视觉上会更吸引人位于图表的右下角)。为此,我希望我需要更改绘图的 x_range
和 y_range
以匹配我的数据范围。
对于低级 plotting.figure
对象,我只需设置 y_range
或 x_range
,但对于高级 bokeh.charts
对象,这些属性似乎不存在.
高级图表的关联属性是什么?如何设置它们?
这是一个情节的 MWE,这个问题说明了我的意思:
defaults.width = 800
defaults.height = 400
output_notebook(hide_banner=True)
data = dict(
python=[2, 3, 7, 5, 26, 221, 44, 233, 254, 265, 266, 267, 120, 111],
pypy=[12, 33, 47, 15, 126, 121, 144, 233, 254, 225, 226, 267, 110, 130],
jython=[22, 43, 10, 25, 26, 101, 114, 203, 194, 215, 201, 227, 139, 160],
)
# data = execs_dat
area = Area(data,
title="Cumulative executive experience at the Wikimedia Foundation",
stack=True,
xlabel='',
ylabel=''
)
show(area)
这是一个视觉效果:
编辑:好的,我第一次弄错了。现在您已经添加了图像,我知道您想要的是将范围限制为 x/y 值的严格 min/max 值。在这种情况下,您可以简单地显式设置 x_range/y_range。例如:
area.y_range = Range1d(0, 270)
如果你还想space超出你的轴边界那么你可以在这里参考我的旧答案:
I'm not entirely sure I understand your question because you asked
about axis and the mention ranges... If got your question right you
can set your labels to '' (as you did) and set min_border_bottom
or
min_border_left
to reduce the related space, since Chart
inherit
from Plot
. So, in your case:
area.min_border_bottom = area.min_border_left = 0
That said, there are current discussion to align Chart
to Figure
so it can share [at least part of] that API as well.
If that is not your question and you think that Chart
is not working
as it should I'd suggest to either to move the discussion to the
mailing list or open an issue on github wh
哪里可以更好地解决它。
下面的图表以及 Bokeh 文档中作为示例提供的许多高级图表都存在一个问题:它在图表的任一侧都造成了不必要的视觉迷惑 space x 轴和 y 轴。参见,例如,this example.
如果图表的角精确地切入坐标轴的边缘(因此我的区域的左下角位于图表的左下角和我的区域的右下角),视觉上会更吸引人位于图表的右下角)。为此,我希望我需要更改绘图的 x_range
和 y_range
以匹配我的数据范围。
对于低级 plotting.figure
对象,我只需设置 y_range
或 x_range
,但对于高级 bokeh.charts
对象,这些属性似乎不存在.
高级图表的关联属性是什么?如何设置它们?
这是一个情节的 MWE,这个问题说明了我的意思:
defaults.width = 800
defaults.height = 400
output_notebook(hide_banner=True)
data = dict(
python=[2, 3, 7, 5, 26, 221, 44, 233, 254, 265, 266, 267, 120, 111],
pypy=[12, 33, 47, 15, 126, 121, 144, 233, 254, 225, 226, 267, 110, 130],
jython=[22, 43, 10, 25, 26, 101, 114, 203, 194, 215, 201, 227, 139, 160],
)
# data = execs_dat
area = Area(data,
title="Cumulative executive experience at the Wikimedia Foundation",
stack=True,
xlabel='',
ylabel=''
)
show(area)
这是一个视觉效果:
编辑:好的,我第一次弄错了。现在您已经添加了图像,我知道您想要的是将范围限制为 x/y 值的严格 min/max 值。在这种情况下,您可以简单地显式设置 x_range/y_range。例如:
area.y_range = Range1d(0, 270)
如果你还想space超出你的轴边界那么你可以在这里参考我的旧答案:
I'm not entirely sure I understand your question because you asked about axis and the mention ranges... If got your question right you can set your labels to '' (as you did) and set
min_border_bottom
ormin_border_left
to reduce the related space, sinceChart
inherit fromPlot
. So, in your case:area.min_border_bottom = area.min_border_left = 0
That said, there are current discussion to align
Chart
toFigure
so it can share [at least part of] that API as well.If that is not your question and you think that
Chart
is not working as it should I'd suggest to either to move the discussion to the mailing list or open an issue on github wh
哪里可以更好地解决它。