Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting Facet/Multi-View Labels in vega-lite

Tags:

vega-lite

vega

Was wondering if there was a way to specify formatting for the Labels of the individual cells in a facet flow.

For example, for something like https://vega.github.io/vega-lite/examples/trellis_barley.html

Can I edit the label font sizes and anchors/baselines for the little labels that say "Grand Rapid Falls", "Duluth", etc.?

The closest thing I've been able to do is globally edit all the labels using a global config, but that also affects other labels like "Trebi", "wisconson No. 38", etc.

Thanks in advance!

like image 397
Justin L. Avatar asked Oct 20 '25 20:10

Justin L.


1 Answers

Labels and titles for facets (including facet, row, and column encodings) are controlled by the "header" property.

For example you could use something like this in the chart you linked to (view in editor)

  "encoding": {
    "facet": {
      ...
      "header": {
        "titleColor": "green",
        "titleFontSize": 40,
        "titleAnchor": "end",
        "labelColor": "red",
        "labelFontSize": 20,
        "labelAnchor": "start"
      }
    }
  }

enter image description here

More information on available label and title configurations can be found in the Vega-Lite Header documentation.

like image 71
jakevdp Avatar answered Oct 22 '25 09:10

jakevdp