Skip to content

Changing position of axis labes does not work #2029

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

Closed
danton267 opened this issue Sep 26, 2021 · 2 comments
Closed

Changing position of axis labes does not work #2029

danton267 opened this issue Sep 26, 2021 · 2 comments
Assignees
Labels

Comments

@danton267
Copy link
Member

library(plotly)
library(ggplot2)

p <- ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(position = 'top')

ggplotly(p)

scale_x_continuous(position = 'top' should move x-labels to the top, however, it does nothing.

@kcbioy
Copy link

kcbioy commented Oct 7, 2021

Still working on this. For the meantime, here's a quick workaround to get the output that you want @danton267

library(plotly)
library(ggplot2)

p <- ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(position = 'top')

ggplotly(p) %>% 
  plotly::layout(xaxis = list(anchor = 'free', position = 1, side = 'top'))

image

@cpsievert
Copy link
Collaborator

cpsievert commented Nov 1, 2021

Unfortunately, I don't think it makes sense to implement position without also adding support for subtitles, captions, and footnotes (because the sizing/placement of these things depend on each other). There is a work-in-progress for this in #929 and I'd be happy to take it over the finish line if @jackparmer wants to support it. However, if we don't take on #929, I'd support promotion of the layout() workaround provided by @kcbioy

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

Successfully merging a pull request may close this issue.

5 participants