Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the axis title #105

Closed
jwhendy opened this issue Jan 7, 2018 · 8 comments
Closed

Changing the axis title #105

jwhendy opened this issue Jan 7, 2018 · 8 comments
Labels

Comments

@jwhendy
Copy link

jwhendy commented Jan 7, 2018

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.

@jwhendy
Copy link
Author

jwhendy commented Jan 7, 2018

Maybe should have looked at the code first. I'm also kind of new to python, but it sort of looks to me like this might not be implemented. The scale class seems to set name=None.

@has2k1 has2k1 added the bug label Jan 7, 2018
@has2k1
Copy link
Owner

has2k1 commented Jan 7, 2018

The name parameter works for naming the titles to the guides of other scales, but it is ignored for the x and y axis titles.

has2k1 added a commit that referenced this issue Jan 7, 2018
 This is inline with the documentation, it was simply ignored for
 the position scales. Other scales were not affected.

 fixes #105
@has2k1 has2k1 closed this as completed in b737828 Jan 7, 2018
@jwhendy
Copy link
Author

jwhendy commented Jan 7, 2018

Installed from master.Tried with both scale_x_continuous and scale_y_continuous and name='foo' works like a champ. Thanks!

@jwhendy
Copy link
Author

jwhendy commented 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.

@jwhendy
Copy link
Author

jwhendy commented May 4, 2018

It looks like you also now allow name='', which is awesome.

Any estimate on this getting pushed to PyPI? I just got a new computer and used pip install plotnine, having forgotten about this issue. I had to re-discover that the name option isn't working on the released version and would guess other users will run into the same.

@has2k1
Copy link
Owner

has2k1 commented May 5, 2018

There are a few issues with the documentation and examples I hoped to sort out before a release. As there are many improvements in master, I think I'll try to make a release in a few days.

@jwhendy
Copy link
Author

jwhendy commented 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.

@has2k1
Copy link
Owner

has2k1 commented May 6, 2018

Are these all in issues?

Some of them are about the doc infrastructure.

If you have an overall strategy (for example, "Replicate R's ggplot2 pages over time"), I will happily help out
The goal is for examples use the geoms (and the rest) as:

  1. Part of a data analysis narrative especially the graphical exploration part.
  2. In an elaborate visualisation to show off the gallery.

However, this criteria is not good for the short term. I did not want to just replicate the examples from ggplot2; we have a similar API and so the examples are easily transferable, but this thinking is slightly biased towards people are somewhat familiar with R.

I appreciate any helping out, my vision for the documentation may not be realistic and after the next release I'll start compromising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants