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

axis_text_x=p9.element_text(margin=...) has no effect #843

Open
TerryGamon opened this issue Jul 16, 2024 · 1 comment
Open

axis_text_x=p9.element_text(margin=...) has no effect #843

TerryGamon opened this issue Jul 16, 2024 · 1 comment
Labels

Comments

@TerryGamon
Copy link

I want to add space between the x-axis labels and the x-axis.
But element_text(margin =) seems to be ignored?

First:

import plotnine as p9
from plotnine.data import mtcars
mtcars=mtcars.head(5)
(p9.ggplot(mtcars)
+ p9.geom_col(p9.aes(x='name',y='mpg'))
+ p9.labs(x='')
)

image

So far so good. Now add space:

(p9.ggplot(mtcars)
+ p9.geom_col(p9.aes(x='name',y='mpg'))
+ p9.labs(x='')
+ p9.theme(axis_text_x=p9.element_text(margin={'t': 40, 'units':'pt'}))  
)

nothing changes

image

just to clarify what I want to achive, here the ggplot dplyr code:

library(tidyverse)

mtcars = as_tibble(mtcars,rownames = "name")
mtcars = mtcars |> head(5)

ggplot(mtcars) +
  geom_col(aes(x=name,y=mpg))+
  labs(x='')+
  theme(axis.text.x = element_text(margin = margin(10)))

image

@has2k1
Copy link
Owner

has2k1 commented Jul 16, 2024

Use axis_ticks_pad.

The margin will work in some future version.

@has2k1 has2k1 added the Layout label Jul 16, 2024
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