There was a previous question that provided the following example which was great at showing what titles get set and how. I'm wondering if someone can help with a little bit more.
My chart is similar to the example below except that I have columns and rows of charts. The columns are based on one variable and the rows are based on other variables. These are for conditional probabilites. At the moment the column names are automatically provided in the same positions as 'setosa', 'versicolor', and 'virginica' in the example which is wonderful.
Here's what I'd like to do and need guidance with:
Given the image below, how can I update the "Y Title"so that it says "Some text" and then a second line with the name of the variable that the row is based on?
How can I get the "Column Title" as well as 'setosa', 'versicolor', and 'virginica' to repeat for each row?
The x-axis values are years. At the moment there's about 10 years and they're squished together. I'd like only a few of the years to appear instead. I'd also like this repeated for each row. I'm thinking this would be considered x-axis tick labels.
I really need to learn the names for all of the chart parts better as well as the in's and out's of faceting. When to facet and when to concatenate...
I hope providing the example in the image below works well to visualize my questions. Let me know if more information is needed.
(Also, if anyone can point me to a great source on learning more about altair that would be great. I'm in the middle of "Jake VanderPlas - Exploratory Data Visualization with Vega, Vega-Lite, and Altair - PyCon 2018" on YouTube currently. Maybe it will be enough but any other pointers at learning this so it's more second nature would be wonderful.)
import altair as alt
import pandas as pd
source = pd.DataFrame(
[
{"a": "a1", "b": "b1", "c": "x", "p": 0.14},
{"a": "a1", "b": "b1", "c": "y", "p": 0.60},
{"a": "a1", "b": "b1", "c": "z", "p": 0.03},
{"a": "a1", "b": "b2", "c": "x", "p": 0.80},
{"a": "a1", "b": "b2", "c": "y", "p": 0.38},
{"a": "a1", "b": "b2", "c": "z", "p": 0.55},
{"a": "a2", "b": "b1", "c": "x", "p": 0.83},
{"a": "a2", "b": "b1", "c": "y", "p": 0.87},
{"a": "a2", "b": "b1", "c": "z", "p": 0.67},
{"a": "a2", "b": "b2", "c": "x", "p": 0.97},
{"a": "a2", "b": "b2", "c": "y", "p": 0.84},
{"a": "a2", "b": "b2", "c": "z", "p": 0.90},
]
)
alt.Chart(source, width=200).mark_bar().encode(
y=alt.Y("c", title=['Some text', 'Variable `c`']),
x="p",
color='c',
row=alt.Row("a:N", title="Factor A", header=alt.Header(labelAngle=0)),
column=alt.Column("b:N", title="Factor B"),
)
'column_name:O'
), or use tickCounts
or values
as in Changing Number of y-axis Ticks in Altair. If that doesn't work, could you ask a new question including code for a Minimal reproducible example?If you have additional specific questions, you can use the example above that has both faceted rows and columns.
Regarding resources, we're updating the documentation to include some additional examples. You can find a list of updated resources in this PR https://github.com/altair-viz/altair/pull/2415/files