Skip to content

multiple axes dislay not working #2028

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

multiple axes dislay not working #2028

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

Comments

@danton267
Copy link
Member

None of these plots display seconds axes properly: https://www.r-graph-gallery.com/line-chart-dual-Y-axis-ggplot2.html

@cpsievert
Copy link
Collaborator

cpsievert commented Nov 1, 2021

I don't think {plotly} will ever be able to support conversion of {patchwork} code (unless we undertook a huge rewrite to convert objects at the {grid} level).

That being said, in most cases, subplot() can be used to do the same thing that {patchwork} operators +, \, etc. do

@cpsievert
Copy link
Collaborator

library(ggplot2)
library(dplyr)
library(hrbrthemes)

# Build dummy data
data <- data.frame(
  day = as.Date("2019-01-01") + 0:99,
  temperature = runif(100) + seq(1,100)^2.5 / 10000,
  price = runif(100) + seq(100,1)^1.5 / 10
)

# Most basic line chart
p1 <- ggplot(data, aes(x=day, y=temperature)) +
  geom_line(color="#69b3a2", size=2) +
  ggtitle("Temperature: range 1-10") +
  theme_ipsum()
  
p2 <- ggplot(data, aes(x=day, y=price)) +
  geom_line(color="grey",size=2) +
  ggtitle("Price: range 1-100") +
  theme_ipsum()

subplot(p1, p2)

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

4 participants