Don't show legend for size with scale.zero = true?
See original GitHub issueVega-Lite outputs always have zero: true
for scale of size
to ensure correct scaling.
However, when zero
is true
, Vega legend always include 0, which looks kinda weird.
For example, in this VG spec from the following VL spec:
{
"description": "A simple bar chart with embedded data.",
"data": {
"values": [
{"a": "A","b": 10},
{"a": "B","b": 20},
{"a": "C","b": 30},
{"a": "D","b": 40}
]
},
"mark": "circle",
"encoding": {
"x": {"field": "a", "type": "ordinal"},
"size": {"field": "b", "type": "quantitative", "scale": {"zero": true, "range": [0, 361]}}
}
}
The field b spans [10,40], but the legend include 0, which is unnecessary.
It’d be great if 0 is excluded.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Hide legend elements that have value zero in ggplot
I am using the "turbo" color scale from Viridis because I need a very wide coverage of colors to be able to distinguish...
Read more >Legend guide — guide_legend • ggplot2
Legend type guide shows key (i.e., geoms) mapped onto values. Legend guides for various scales are integrated if possible.
Read more >Controlling legend appearance in ggplot2 with override.aes
Changing the legend appearance without changing the plot appearance can be done using the override.aes argument in guide_legend().
Read more >Legend | Vega-Lite
Similar to axes, legends visualize scales. ... If set to true (default) or "parity" , a strategy of removing every other label is...
Read more >15 Scales and guides | ggplot2
A legend can display multiple aesthetics (e.g. colour and shape), from multiple layers (Section 15.7. · Axes always appear in the same place....
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
Right now I’m experimenting with the following and so far it seems to work well: Remove a zero-sized entry if and only if (1) there is an active size encoding driving the legend, (2) the removed value is the first entry in the legend, and (3) the removed value was generated from the scale domain, not supplied as part of an explicit
values
array. Sound good?(Note that our legend entry generator has access to the backing scales, but not their Vega specs, so we don’t know if
zero: true
is set or not.)Suppression of initial zero-sized legend entries was included in the
v3.0.0-beta.15
release.