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.

Changing the axis title

See original GitHub issue

Hello,

I’m coming from R + ggplot2 and I’m not sure what I’m doing wrong here to change the axis title.

from plotnine import *
from plotnine.data import *
p = ggplot(aes(x='displ', y='cty'), mpg) + scale_x_continuous(name="foo")
p + geom_point()

2018-01-06_222203

From the docs

class plotnine.scales.scale_x_continuous(**kwargs) name (str, optional) – Name used as the label of the scale. This is what shows up as the axis label or legend title.


R equivalent:

library(ggplot2)
data(mtcars)

ggplot(mtcars, aes(x=disp, y=mpg)) + geom_point() + scale_x_continuous(name="foo")

2018-01-06_222650

Thanks for taking a look, and sorry if I’ve misunderstood due to being new to plotnine.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jwhendycommented, Feb 11, 2018

Update: when I use ggplot2, I’ll frequently do scale_y_continuous("") when the label is obvious or unhelpful.

I just found that passing an empty string reverts to whatever the column label is. In other words, name='foo' works, but not name=''. I can pass a space to hack this, but wanted to bring it up.

Taking an empty string would match ggplot2 behavior to remove an axis label.

1reaction
jwhendycommented, May 5, 2018

Are these all in issues? I’ve been using R’s ggplot2 for maybe 7 years and the fact that you’ve built it for python is about the coolest thing ever. I’ve putzed with some other libraries, but when I just need to get something done, I use this!

tl;dr version: do you need help with some of these things? I can certainly write up some examples. For example I noticed there aren’t any for geom_text() and annotate() yesterday…

If you have an overall strategy (for example, “Replicate R’s ggplot2 pages over time”), I will happily help out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change axis labels in a chart in Office - Microsoft Support
Right-click the category labels to change, and click Select Data. ... In Horizontal (Category) Axis Labels, click Edit. In Axis label range, enter...
Read more >
How to Add Axis Labels in Excel Charts - Step-by-Step (2022)
How to add axis titles. 1. Left-click the Excel chart. 2. Click the plus button in the upper right corner of the chart....
Read more >
ggplot2 title : main, axis and legend titles - Easy Guides - Wiki
Change the appearance of the main title and axis labels ... The arguments below can be used for the function element_text() to change...
Read more >
Excel charts: add title, customize chart axis, legend and data ...
In Excel 2013 - 365, a chart is already inserted with the default "Chart Title". To change the title text, simply select that...
Read more >
How to Change Chart Names on the Vertical & Horizontal Axis ...
Click Design on the main menu, then Layout and finally, select Axis Title or Data Labels according to which you want to modify....
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