Legend colors missing
See original GitHub issueI have Vega3 installed and using the latest Jupyter notebook I am attempting to plot a bar chart with a legend. While colors are shown correctly in the chart, the corresponding colors are missing in the legend labels.
alt.Chart(df).mark_bar().encode(
alt.X('subset:O', axis=alt.Axis(title='Subset')),
alt.Y('sum(sha256):Q', axis=alt.Axis(title='Number of samples')),
alt.Color('label:N', scale=alt.Scale(range=["#3333ff", "#ff3333"]), legend=alt.Legend(values=["Cat1", "Cat2"]))
)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
PlotLegend Colors Missing - Mathematica Stack Exchange
I want a PlotLegend with the colors of the graphics. p4 = Plot[y1[t] /. s1, {t, 0, tmax}, PlotRange -> All, PlotStyle ->...
Read more >Missing legend when specify color using fill in geom_bar ...
Is there a way to add legends back? When I specify the color for each bar, The legend disappeared.
Read more >The legend box in plot has no colors - MATLAB Answers
The legend box in matlab has no colours. This is the code: x = linspace(0,pi);. y1 = cos(x);. plot(x,y1,'DisplayName','cos(x)'). hold on. y2 =...
Read more >Missing raster symbology colors in legend on Online Scene
Everything is in the scene correctly, but my slope raster classification colors are not showing in the legend, only the labels. Is this...
Read more >Legend in excel chart does not show the colors for the data ...
Three series have only one point and they are overlapped using the series overlap feature in formatting. They display fine on the chart....
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
Ah – so you’re setting the legend values to values that are not in your dataset, so there are no associated markers for those values.
If you want your legend to reflect labels that do not exist in your data, the best approach is to transform your data. You can either do this as a preprocessing step (i.e. modify the actual dataframe) or by using a transform within the chart specification. As an example of the latter approach, see this example figure where a column of zeros and ones is mapped to “Male” and “Female” within the chart.
Here is a minimal dataframe which can be re-created to produce the problem.