Domain legend gets squished when horizontal in colab vs vertical in vega-lite editor
See original GitHub issueIn colab, the legend gets squished so that the text is unreadable when there are multiple breakpoints.
Code to reproduce:
import altair as alt
from vega_datasets import data
counties = alt.topo_feature(data.us_10m.url, 'counties')
unemp_data = data.unemployment.url
alt.Chart(counties).mark_geoshape().encode(
color=alt.Color('rate:Q',
scale=alt.Scale(type="linear",
domain=[.02,.02,.035,.035,.05,.05,.065,.065,.08,.08,.095,.095,.11,.11,.125,.125,.14,.14,.155,.155],
range=
["#5e4fa2","#5e4fa2",
"#3288bd","#3288bd",
"#66c2a5","#66c2a5",
"#abdda4","#abdda4",
"#e6f598","#e6f598",
"#fee08b","#fee08b",
"#fdae61","#fdae61",
"#f46d43","#f46d43",
"#d53e4f","#d53e4f",
"#9e0142","#9e0142"])),
).transform_lookup(
lookup='id',
from_=alt.LookupData(unemp_data, 'id', ['rate'])
).project(
type='albersUsa'
).properties(
width=500,
height=300
)
In the vega-lite editor, this gets rendered as a vertical legend.
{
"config": {"view": {"width": 400, "height": 300}},
"data": {
"url": "https://vega.github.io/vega-datasets/data/us-10m.json",
"format": {"feature": "counties", "type": "topojson"}
},
"mark": "geoshape",
"encoding": {
"color": {
"type": "quantitative",
"field": "rate",
"scale": {
"domain": [
0.02,
0.02,
0.035,
0.035,
0.05,
0.05,
0.065,
0.065,
0.08,
0.08,
0.095,
0.095,
0.11,
0.11,
0.125,
0.125,
0.14,
0.14,
0.155,
0.155
],
"range": [
"#5e4fa2",
"#5e4fa2",
"#3288bd",
"#3288bd",
"#66c2a5",
"#66c2a5",
"#abdda4",
"#abdda4",
"#e6f598",
"#e6f598",
"#fee08b",
"#fee08b",
"#fdae61",
"#fdae61",
"#f46d43",
"#f46d43",
"#d53e4f",
"#d53e4f",
"#9e0142",
"#9e0142"
],
"type": "linear"
}
}
},
"height": 300,
"projection": {"type": "albersUsa"},
"transform": [
{
"lookup": "id",
"from": {
"data": {
"url": "https://vega.github.io/vega-datasets/data/unemployment.tsv",
"format": {"type": "tsv"}
},
"key": "id",
"fields": ["rate"]
}
}
],
"width": 500,
"$schema": "https://vega.github.io/schema/vega-lite/v2.4.3.json"
}
Incidentally, the legend is in the vega-lite editor is unfortunately also inaccurate, which I’ve reported on the vega-lite repo: https://github.com/vega/vega-lite/issues/3981
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Encoding | Vega-Lite
By default, Vega-Lite automatically generates a scale and a legend for each field mapped to a mark property channel. If unspecified, properties ...
Read more >vega grouping difference for vertical and horizontal bar chart?
I am trying to make a grouped bar chart with Vega. So I took the "stacked bar chart example" data (removed the stacking...
Read more >Untitled
#Train Disintegration of ussr and india, A cold wall brand, Berocca energy tablets, Resumen compendio sinonimo, Romansas dviems akordai.
Read more >Text Classification - Colaboratory - Google Colab
Collect a vocabulary of all tokens that appear in documents and number them. Encoding. Count how often each word appears in each document....
Read more >Simple index - piwheels
... odoo-addon-disable-odoo-online first-pip-foo cookiecutter-leonardo-module example-pkg-ketanmb69 domain-discovery plover-word-tray pygame-spritesheet ...
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
Hi Jeff -
Thanks for the quick reply!
Yes - I was trying to force a threshold scale type, since I saw it wasn’t an option in Vega-Lite. Can I make a feature request? 😃
sweet!
Yay! Glad to hear it.
Alas!
Works like a charm - thanks!