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.67k stars 608 forks source link

Shape encoding and legend issues #3208

Open jwoLondon opened 6 years ago

jwoLondon commented 6 years ago

Sorry for the long post but I think the following issues are related so I thought it clearer to keep together for the moment. While some are more points for discussion, I think there are also some bugs too. They all relate to encoding with shape and other channels.

All examples can be found in this block

Issue A

Encoding ordinal data with the shape channel generates two warnings:

ordinal data encoding with shape

Shape channel should be used with nominal data only

Using discrete channel "shape" to encode "ordinal" field can be misleading as it does not encode order.

I would argue the second of these warnings is helpful and is consistent with Bertin's recommendations, but the first is unnecessary, being both too strong and redundant given the second one. I think there are limited cases were encoding ordinal data with shape is meaningful, or at least not entirely wrong (espeically if using custom shapes). One can eliminate the warning by casting an ordinal field as nominal, but this seems semantically incorrect.

Issue B

Encoding ordinal data with the size channel generates the warning:

Channel size should not be used with discrete field.

For nominal data that warning makes sense, but for ordinal data it contradicts Bertin's recommendation. There are certainly cases where encoding ordinal data with size can be valid. Perhaps a more cautious warning would be better, such as

Care should be taken when using channel 'size' to encode an 'ordinal' field as this can sometimes give a misleading impression of relative magnitude.

Issue C

Related to Issue B, when encoding ordinal data with size, the relative sizings appear neither linear or quadratic, see for example:

Fixed shape, sized by ordinal category

The inconsistency in size is even more apparent when double encoding with shape:

double encoding of shape and size by ordinal category

Perhaps consider a more balanced scaling? There is an opportunity here to use a Flannery perceptual scaling.

It would appear that when using custom SVG paths (example below uses SVG path for square of unit size) to represent shapes, the relative sizing is better, so there appears to be at least an inconsistency here:

Custom shape sized by ordinal category

Issue D

When a mark has "filled": true, the legend correctly fills the symbols when fields are encoded by size, shape or opacity. But if a separate field is encoded by colour, the shape, size legend items are no longer filled. This is inconsistent with the other legend rules (a default circle is used in both legend sets, but the default blue is not).

Filled legend when encoding with colour and shape channels Unfilled legend when encoding with colour and shape channels

Issue E

Use of custom SVG path shapes seems to assume an area of around 1 (in pixel coordinates). If a larger area is used, which can be legitimate in some cases such as Isotype symbolisation, the legend uses the size of the custom shape rather than scaling it to fit within a line of legend text:

Oversized legend with custom shapes

I think this is a bug rather than feature, but in fixing it there is an opportunity to clarify in the documentation what an appropriate area for custom SVG path symbols should be.

Issue F

When double-encoding a custom shape with another channel (or triple-encoding or higher), the legend separates the shape from other encodings. This is inconsistent with the legend rules for default shapes (which are correctly combined) and creates unnecessarily verbose legends for custom shapes:

Correct double encoding of default shape and colour Verbose legend for double encoding of custom shape and colour

This may be related to issue D.

kanitw commented 6 years ago

Thanks for your detailed report. Here are my replies.

TODO

domoritz commented 6 years ago

Looks like we fixed the warning in issue B.

domoritz commented 6 years ago

Issue D also seems fixed.

image

domoritz commented 6 years ago

I fixed A in https://github.com/vega/vega-lite/pull/4200