vega / vega-lite

A concise grammar of interactive graphics, built on Vega.
https://vega.github.io/vega-lite/
BSD 3-Clause "New" or "Revised" License
4.66k stars 607 forks source link

Revise default legend #3853

Closed kanitw closed 5 years ago

kanitw commented 6 years ago

1) It seems liked the default legend orient is changed when we upgraded to Vega 4 rc -- not sure if this is simply due to Vega 4's changed default?

Since we didn't have a check to always re-compile examples until recently: https://github.com/vega/vega-lite/commit/cba6f359128792b90ca66fe04d86f9b36bfaa5d0. This change slipped through our releases.

2) This leads to some better orient

image

But this also leads to so many examples that has very imbalanced layout.

image

image

I think horizontal is still a better default since it looks less worse in many general cases. For example, even when the plot is tall enough but the legend's field has long title it still looks imbalanced.

Plus, this will be more inline with previous behavior prior to 2.5.

image

tonne1 commented 6 years ago

Seems like it mainly looks messy because you give the legend a fixed height. If you adapt the legend to the height of the chart, it should be ok, especially for continous legends. It might not be feasible for ordinal legends with many items.

domoritz commented 6 years ago

As a side note, if you continue to use Vega 3 nothing changes but charts look different in Vega 4.

kanitw commented 6 years ago

Seems like it mainly looks messy because you give the legend a fixed height. If you adapt the legend to the height of the chart, it should be ok, especially for continous legends. It might not be feasible for ordinal legends with many items.

I like this suggestion. We could try to see if we can set the legend height only for continuous legends.

domoritz commented 6 years ago

You have to keep the height of the title in mind, though. I filed an issue about legend titles in https://github.com/vega/vega/issues/1279

domoritz commented 6 years ago

Ther is an issue if we have multiple legends as they take up a lot of vertical space. See https://github.com/vega/vega-lite/issues/3873

domoritz commented 6 years ago

We could count the number of legends and divide the space equally. Or automatically change to horizontal legends if there is more than one scale. I think I prefer the latter.

domoritz commented 6 years ago

I think the new default is fine but we might want to a) automatically set the gradient length b) change the default direction when there are more than one legend.

kanitw commented 5 years ago

Vertical is probably good default in Vega because people tend to customize things more in Vega.

However, in Vega-Lite, there are so many cases where this can be broken.
I'd say that horizontal is a more conservative choice, taking Tableau as inspiration.

For example, vertical legend here leads to so much wasted space and imbalance for aggregated field (which happens so often in VL, but you won't have similar title in Vega.)

untitled

Way less space wasted

image

I think the vertical one is better for the map examples though. But if our optimization goal is to minimize layout imbalance and % of wasted space, then I think horizontal fits our optimization goals in VL better.

b) change the default direction when there are more than one legend.

So far, we actually generally avoid a design where one focused change affects another change. Thus, I'd argue that this design is bad. (Adding one encoding channel should not change the legend of an existing channel. The encoding should be orthogonal.)

a) automatically set the gradient length

This might be okay. But how would you set it in such as way that works for multiple legends, esp. if one is continuous and another is discrete?

kanitw commented 5 years ago

Since changing the orientation is also easy enough, we could make horizontal the default, but customize our map examples to use "vertical".

kanitw commented 5 years ago

Let's outline all different cases

1) Continuous scale

1a) with reasonable height

concat_marginal_histograms

image

rect_binned_heatmap.svg

image

1b) with a bit small plots

image

rect_heatmap

image

rect_heatmap_weather

image

rect_lasagna_future

image

2) binned color

image

It's unclear to me why binned color legend should look different from quantize scale's legend

image

3) Geo -- vertical is clear better (unless the color field name is long)

geo_choropleth

image

geo_repeat

image

4) Temporal

line_quarter_legend -- both of these seem wrong? -- quarter should be discrete

image

point_dot_timeunit_color (This might be the case where horizontal makes more sense as it is temporal?

image