Subtitle Documentation and styling
See original GitHub issueAt last! There are subtitles in for altair charts(via a vega-lite update)! How splendid! This issue identifies a documentation bug and maybe a styling bug revolving around this newly birthed feature:
-
I don’t believe that there is any documentation of the mechanism for adding subtitles (or multiline titles) to charts! It’s a great feature it should be easy to find!
-
The title configuration section of the documentation appears to suggest that there should be various subtitle styling operators (subtitleColor, subtitleFont, subtitleFontSize, subtitleFontStyle, subtitleFontWeight, subtitleLineHeight, subtitlePadding specifically), but all of the variations that i’ve tried on them appear not to work? For instance the following should ostensibly produce a chart with a red subtitle
import altair as alt
from vega_datasets import data
chart = alt.Chart(data.cars.url).mark_point().encode(
x='Horsepower:Q',
y='Miles_per_Gallon:Q',
).properties(
title={
"text": ["First line of title", "Second line of title"],
"subtitle": ["Cool first line of subtitle", "Even cooler second line wow dang"]
}
)
chart.configure_title(
fontSize=20,
font='Courier',
anchor='start',
color='gray',
subtitleColor='red'
)
Unfortunately it produces a chart with an unstyled subtitle:
I totally admit that i might be misreading this, but, if not, it seems like a bug. I’m happy to help contribute documentation once a solution is known
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top GitHub Comments
Apparently it is both a documentation bug and a regular bug, after a helpful hint from @domoritz on the upstream issue, I was able to get the styling applied to the subtitle like so:
@jakevdp, I’m interested in the idea of adding examples to the gallery that tackle basic customizations like adding a subtitle. Would you be open to a new section there that showed how to do something like this? It seems like it would pretty tough for a newbie to figure out.