English 中文(简体)
如何避免在海图边缘点被切断
原标题:How to avoid points being cut off at the edges of the chart
  • 时间:2024-02-22 07:25:05
  •  标签:
  • altair

Using the default configuration, points in Altair plots are sometimes cut off at the edges of a chart (here left and top): Example Altair chart

这是编制图表的法典:

df = pd.DataFrame({
    "X": [0.01, 0.05, 0.1, 3.0, 3.1, 3.2],
    "Y": [1.0, 1.1, 1.2, 2.9, 2.98, 2.99]
})
chart = alt.Chart(
    df,
).mark_point().encode(
    x= X ,
    y= Y ,
).properties(
    width=400,
    height=350
).interactive()
chart

I have read about clip, clamp and padding, but they do not fit my needs. With clip users of the chart (when it is interactive) can move the plot outside the chart window, which I would like to prevent. clamp is a different form of visualization, also not what I want here. And with padding I get inconsistent results with the data points then sometimes being very far away from the axes.

So my question is, how can I globally configure Altair to always show all points in full? Hopefully, there is a way to achieve this that does not require manually setting the scale domains every time. Thanks a lot for your help.

Kind regards,
Axel

问题回答

请删除<代码>。 我认为,你会得到你们的希望:

“entergraph

如果你在两张图表上点击三条行动菜单(有或没有“互动”),并选择在维加编辑中浏览,你将看到<代码>互动<>。 增加本节:

  "params": [
    {
      "name": "param_2",
      "select": {"type": "interval", "encodings": ["x", "y"]},
      "bind": "scales"
    }
  ],

这里没有任何东西可以由提尔控制,而是由维加-利特控制,因此,我会在那里提出一个问题,问为什么增加一些小军火(或可能是特别有规模的束弹),会改变各点的表现。





相关问题
Squeeze x-axis 日期

我有一张burn缩的图表,显示轴和轴上其余物体的日期。 有时,我拥有大量的“停滞”数据(X-amount时间未完成任何物体)。 ......

热门标签