line-and-point legends
See original GitHub issueI need a Line Chart with Points plots and there is an example. It states that altair.Chart(data).mark_line(point=True)
will produce line chart with points.
Since I have multiple series to plot I specified color='kind'
, strokeDash='kind'
(or both). I found that the legends are only circles.
- With
color='kind'
, the circles are filled with the colors. - With
strokeDash='kind'
, the boundary of the circles are solid or dashed lines.
Without point=True
I have lines and the effects are that lines are colored or dashed. With both point=True
and {color='kind'
, strokeDash='kind'
, or both} I would expect the legends to have both lines and circles, same appearance as plot. I couldn’t figure out how to achieve the desired behavior so that I am opening this issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Legend with both point and line in R - Stack Overflow
What I actually want in the legend is to make the point and the line side-by-side instead of on top of each other,...
Read more >Different Colors of Points & Lines in Base R ... - Statistics Globe
In this R tutorial you'll learn how to display the same legend item with different colors of points and lines. The table of...
Read more >Legend of mixed line and point plots - Google Groups
Dear all, I would like to plot a mixture of lines and points in a plot. Well, it works however I think the...
Read more >Is there an easier way to have point and line legend labels ...
Is there an wasier way to have point and line legends group together for the same group level (so the 'a' legends are...
Read more >Legends (ggplot2) - Cookbook for R
You want to modify the legend of a graph made with ggplot2. ... scale_shape_xxx instead of scale_fill_xxx . colour maps to the colors...
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 Free
Top 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
Thanks for providing an example @majiang! Currently it is not possible to combine legends of points and lines, you can follow the discussion here https://github.com/altair-viz/altair/issues/1785 and upstreams in vega-lite here https://github.com/vega/vega-lite/issues/5996
If you append
.resolve_scale(color='independent', strokeDash='independent')
to your chart, you can get something like this:The title can be removed from one of the legends by setting
title=''
for that encoding channel.Sorry for not being able to try and feedback that time.
I now think it is impossible due to vega-lite’s limitation and describe it with examples.
The desired output was something like
which I created with Excel. By “line-and-point legend” I meant line legend and point legend combined as they look.
With altair, when I opened this issue,
produced
the main part of which was satisfactory, but only legend was not.
I have also tried
which produces similar result:
Here I don’t mind whether the circles are filled or not.
Since the appearance of legend of a
Chart
is determined fully automatically by vega-lite from the definition of encoding channels, we can’t produce the desired output.