question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to rotate the y-axis label and sit in the upper left corner?

See original GitHub issue

Many news charts rotate the y-axis label so it can be read left to right and lift it to sit above the top of the axis. I’ve roughly recreated this in Altair, but longer axis titles generate this bug. Any idea how to fix it? I don’t see a text anchor setting in Vega-Lite I can use.

visualization 2

import altair as alt
from vega_datasets import data

source = data.iowa_electricity()

alt.Chart(source, title="Iowa's renewable energy boom").mark_line().encode(
    x=alt.X(
        "year:T",
        axis=alt.Axis(title="Year")
    ),
    y=alt.Y(
        "net_generation:Q",
        title="Net generation (in thousand megawatthours)",
    ),
    color=alt.Color(
        "source:N",
        legend=alt.Legend(title="Electricity source"),
    )
).configure_axisY(
    titleAngle=0,
    titleY=-10,
    titleX=-10,
)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
palewirecommented, Jan 28, 2019

I guess I can close the ticket now. I doubt anyone cares, but IMHO this should be the y-axis’s default title position. Commonplace in media. Much more legible.

1reaction
palewirecommented, Jan 28, 2019

Looks like there’s an axis setting now called titleAlign. If I put “left” in there it seems to work.

download

import altair as alt
from vega_datasets import data

source = data.iowa_electricity()

alt.Chart(source, title="Iowa's renewable energy boom").mark_line().encode(
    x=alt.X(
        "year:T",
        axis=alt.Axis(title="Year")
    ),
    y=alt.Y(
        "net_generation:Q",
        title="Net generation (in thousand megawatthours)",
    ),
    color=alt.Color(
        "source:N",
        legend=alt.Legend(title="Electricity source"),
    )
).configure_axisY(
    titleAngle=0,
    titleAlign="left",
    titleY=-10,
    titleX=-10,
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

BarChart: Want to rotate and place a y-axis label on the left side
I would like to know if it's posible to place the y-axis label roated on the left side without using Frame->True and FrameLabel->...
Read more >
Rotating axis labels in R plots - Tender Is The Byte
A detailed look at how to rotate axis labels in base R plots.
Read more >
Quick and easy ways to deal with long labels in ggplot2
First we can rotate the labels a little. Here we rotate the labels 30°, but we could also do 45°, 90°, or whatever...
Read more >
Origin Help - Graph Axes - OriginLab
For information on... These customizations... See these topics in the Origin Hel... Major tick labels Show/hide labels on major ticks Tick Labels tab Major tick...
Read more >
Rotating shapes (video) - Khan Academy
Sal is given a triangle on the coordinate plane and the definition of a rotation about ... Is there an easier way or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found