cbrnr
cbrnr

Reputation: 1751

Fix axis scale in interactive charts

I want to visualize non-negative data (e.g. 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()

enter image description here

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?

Upvotes: 2

Views: 286

Answers (1)

jakevdp
jakevdp

Reputation: 86463

No, Vega-Lite & Altair don't provide any way to limit interactive axes to a particular range of values.

Upvotes: 2

Related Questions