Color and Shape Legends Not Combined in Line Chart or Multiple Charts
See original GitHub issueCode to reproduce:
In line chart:
df = pd.DataFrame(
data=[[0, 10, "a"], [1, 20, "a"], [0, 15, "b"], [1, 25, "b"]],
columns=["x", "y", "c"]
)
alt.Chart(df).mark_line().encode(
x="x",
y="y",
color="c",
shape="c"
)
Multi Charts:
df = pd.DataFrame(data=[[0, 10, "a"], [1, 20, "a"], [0, 15, "b"], [1, 25, "b"]], columns=["x", "y", "c"])
points = alt.Chart(df).mark_point().encode(x="x", y="y", color="c", shape="c")
lines = alt.Chart(df).mark_line().encode(x="x", y="y", color=alt.Color("c", legend=None))
points + lines
Expected behaviour
The legend should be like this:
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Tableau Tutorial - Combining color / shape legends into one ...
Occasionally, I will put a dimension on both the color and shape cards to increase the contrast to make a scatter plot easier...
Read more >Vary the colors of same-series data markers in a chart
Set varying colors of data markers (bars, columns, lines, pie or doughnut slices, dots, and other shapes) automatically in an Office chart.
Read more >Combine legends for color and shape into a single legend
Currently I have 2 legends, one for the colors and one for the two shapes. How can I combine them into a single...
Read more >A Complete Guide to Line Charts | Tutorial by Chartio
The ability to plot multiple lines also provides the line chart a special use case where it might not usually be selected. Normally,...
Read more >Be Awesome in ggplot2: A Practical Guide to be Highly Effective
Geometry corresponds to the type of graphics (histogram, box plot, line plot, ... Point shapes, colors and size; Add text annotations to a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
These are probably questions to raise in the Vega-Lite forums.
One note: the last chart will work as expected if you use a
detail
encoding as well, which controls how data is grouped without adding a visual attribute:For reference, the corresponding Vega-Lite issue is here https://github.com/vega/vega-lite/issues/5996