简体   繁体   English

修复交互式图表中的轴比例

[英]Fix axis scale in interactive charts

I want to visualize non-negative data (eg heights or weights).我想可视化非负数据(例如身高或体重)。 Here's an example:下面是一个例子:

import pandas as pd
import altair as alt

data = pd.DataFrame({'a': list('CCCDDDEEE'),
                     'b': [2, 7, 4, 1, 2, 6, 8, 4, 7]})
alt.Chart(data).mark_point().encode(
    x='a',
    y='b'
).interactive().show()

在此处输入图片说明

I can interactively pan the y-axis of the chart (not possible in the static image above), but it doesn't make sense that I can go below 0. Is it possible to fix the y-axis to positive values somehow?我可以交互地平移图表的 y 轴(在上面的静态图像中不可能),但是我可以低于 0 没有意义。是否可以以某种方式将 y 轴固定为正值?

不,Vega-Lite 和 Altair 不提供任何方法来将交互轴限制为特定范围的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM