Reputation: 401
I am using Altair 4.1.0 to create interactive plots with Python. I want to be able to zoom in some part of my chart by scaling only one axis, for example only the y-axis while keeping the x-axis fixed. From the documentation I could not find a way to do this. My understanding is that alt.interactive()
corresponds to .add_selection(alt.selection_interval(bind='scales'))
, but still I don't see how to achieve my purpose. Is there any way to do this in Altair?
Upvotes: 1
Views: 2173
Reputation: 86330
alt.Chart.interactive
has bind_x
and bind_y
arguments which default to True
. If you set either of these to False
, that scale will not be part of the interaction:
chart.interactive(bind_x=False)
Alternatively, you can do this manually by specifying the encodings you want bound (['x']
, ['y']
, or ['x', 'y']
, which is the default):
chart.add_selection(alt.selection_interval(bind='scales', encodings=['y']))
Upvotes: 2