-
-
Notifications
You must be signed in to change notification settings - Fork 668
Description
What happened?
In PyCharm / Jupyter Notebook, if I plot a bar chart with according number-labels like in this example (but vertical) and make the chart interactive, the label of the highest bar (79) gets cut off. If I leave the call to .interactive() out, the label will be displayed.
import polars as pl
import altair as alt
print(f"Altair {alt.__version__}")
df = pl.DataFrame({"X": ["A", "B", "C"], "Y": [42, 21, 79]})
base = alt.Chart(df).encode(x='X', y='Y')
c = alt.layer(
base.mark_bar().encode(color='X'),
base.mark_text(dy=-2, baseline='bottom').encode(text='Y')
).properties(
width=200,
height=150,
title=f'Hello World!',
)
# watch the label 79 at "C"-bar: it gets cut off if set to interactive!
alt.hconcat(*[c, c.interactive()])
On the right, the interactive chart with cut-off label, on the left non-interactive. Scrolling the interactive chart, the label will get revealed:
What would you like to happen instead?
In both modes, interactive and not, the chart should look initially the same and contain also the label of the tallest bar.
Or at least provide a way to scale the axis so that everything will be displayed, even if offset by dy/baseline. (I first hacked a workaround calculating a custom scale/domain of 105% of max value, but to really need this, would be very ugly IMHO.
Thanks!
(BTW: I tried to load the chart in Vega-Editor as proposed in the issue form, but the result was empty and showed an error. And I had to reload the Notebook in PyCharm after that... Well...)
Which version of Altair are you using?
5.5.0