Closed ht1212 closed 2 months ago
Having the same issue - @ht1212 did you ever find a solution?
Thanks for bringing this back to my attention. I have issued a fix that works for top/bottom/left/right axes.
remotes::install_github("hafen/geofacet")
library(geofacet)
library(ggplot2)
state_unemp$dummy_variable_axis <- state_unemp$rate + 15
ggplot(state_unemp, aes(year, rate)) +
geom_line() +
geom_line(state_unemp, mapping=aes(x=year, y=dummy_variable_axis))+
facet_geo(~ state, grid = "us_state_grid2", move_axes = TRUE) +
scale_x_continuous(
labels = function(x) paste0("'", substr(x, 3, 4)),
sec.axis = sec_axis(transform = ~ ., name = "Dummy x axis")
) +
ylab("Unemployment Rate (%)") +
scale_y_continuous(
sec.axis = sec_axis(transform = ~ ., name = "Dummy y axis")
)
This should work if you install from GitHub. I want to wait until I get more user-submitted grids integrated into the package before releasing to CRAN again though.
I'm using geo_facet and is working great apart from when I'm including a secondary y axis (for my sins) using
sec_axis()
.I'm coming across the issue where the axis labels and ticks for the right side yaxis are not moved to the closest panel but instead show for every grid row at the furthest right hand side of the plot. See the example below:
Is there any possibility to have these secondary axis moved to the closest panel as is currently done with the left axis?
Thanks!
here is my
session_info()
call: