简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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