🏠 back to Observable

How can I change the axis titles freely in Vega-Lite, without changing the key of the data

Dear all, how can I change the axis titles freely in Vega-Lite, without changing the key of the data? For instance, changing the original axis titles “A”,“B”, “C” to AA, BB, CC ?

https://observablehq.com/d/e48f777c4b3c5232

Normally you’d specify a “title” key for your axis. Not sure though if there’s a way to do it dynamically.

Thank you very much. The thing is I have a title with ‘℃’. If I have this symbol in my data files, it cannot be read with the file reading codes in my link. Thus I was wondering how to make ‘℃’ can be read?

At least for your marginalHistograms_1 cell you can set a custom label via .title(), e.g.:

const y = vl.y().fieldQ("B").scale({ zero: false }).title("℃");