🏠 back to Observable

rotate text labels with VegaLite in Observable

I can’t find a way to rotate the text labels for the “Name” labels up top. I am working in Observable notebook. Here is the code:

  width: 50,
  data: { values: StackVega },
  mark: 'bar',
  encoding: {
    column: {
      field: "new_name",
      type: "nominal",
      spacing: 2,
      title: "Name"
      // rotate:
    y: {
      type: "quantitative",
      aggregate: "sum",
      field: "new_rate",
      title: "Rate",
      axis: { grid: false }
    x: { type: "nominal", field: "stat", axis: { title: "" } },
    color: {
      type: "nominal",
      field: "stat",
      scale: { range: ["#675193", "#ca8861"] }
  config: {
    view: { stroke: "transparent" },
    axis: { domainWidth: 1 }

I have tried to add axis: { labelAngle: -50 } but that didn’t do anything.

When you are using “column” (or “row”), you need to use “header” instead of “axis”. So in this case I think you’d add something like
header: {labelAngle: -90}
to your column specification.

See Header | Vega-Lite

However, unfortunately it looks like there are some bugs in Vega-Lite which mean that changing the angle and orientation of these labels doesn’t work very well: