Repository navigation
Closed
Description
When trying to force the axis ticks to be inside the figure (using negative axis.ticks.length) from all sides (using dup.axis), the ticks appear on the outside of the strip text. Previous versions used to plot the ticks correctly inside the plot
Here is an example of this
library(ggplot2)
ggplot(mpg, aes(displ, cty)) +
geom_point() +
facet_grid(drv~cyl) +
scale_y_continuous(sec.axis = dup_axis()) +
scale_x_continuous(sec.axis = dup_axis()) +
theme(strip.placement = "outside",
axis.text.x.bottom = element_text(margin = margin(5,0,0,0)),
axis.text.y.left = element_text(margin = margin(0,4,0,0)),
axis.text.x.top = element_blank(), axis.title.x.top = element_blank(),
axis.text.y.right = element_blank(), axis.title.y.right = element_blank(),
axis.ticks.length = unit(-3, "point")) Running this code on ggplot2 v3.4.1 produces this image

Note that the ticks are outside the strip text
While running the code on older versions (e.g. v3.3.1) produces the ticks in the right place. see image below
Session info for the top image
> sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────
setting value
version R version 4.2.2 (2022-10-31 ucrt)
os Windows 10 x64 (build 19045)
system x86_64, mingw32
ui RStudio
language (EN)
collate English_Canada.utf8
ctype English_Canada.utf8
tz America/Denver
date 2023-03-27
rstudio 2022.12.0+353 Elsbeth Geranium (desktop)
pandoc NA
─ Packages ──────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
cli 3.6.1 2023-03-23 [1] CRAN (R 4.2.3)
colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.2.2)
dplyr 1.1.1 2023-03-22 [1] CRAN (R 4.2.3)
fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.2)
farver 2.1.1 2022-07-06 [1] CRAN (R 4.2.1)
generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.1)
ggplot2 * 3.4.1 2023-02-10 [1] CRAN (R 4.2.3)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.1)
gtable 0.3.3 2023-03-21 [1] CRAN (R 4.2.3)
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.2.0)
lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.1)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.1)
pillar 1.9.0 2023-03-22 [1] CRAN (R 4.2.3)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.1)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.1)
rlang 1.1.0 2023-03-14 [1] CRAN (R 4.2.3)
rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.1)
scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.1)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.1)
tibble 3.2.1 2023-03-20 [1] CRAN (R 4.2.3)
tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.1)
utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.2)
vctrs 0.6.1 2023-03-22 [1] CRAN (R 4.2.3)
withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.1)
[1] C:/Users/mod_m/AppData/Local/R/win-library/4.2
[2] C:/Program Files/R/R-4.2.2/library
─────────────────────────────────────────────────────────────────────────────────
Activity
[-]negative axis.ticks.length forces strip.placement to be inside[/-][+]negative `axis.ticks.length` forces `strip.placement` to be inside[/+]teunbrand commentedon Mar 27, 2023
Thanks for the report! I can confirm this bug.
teunbrand commentedon Apr 3, 2023
Here is a more minimal reprex:
Created on 2023-04-03 with reprex v2.0.2