I have a facet_wrap that looks good; however, I want to only have the external lines with actual numerical data and the internal graph lines with tick marks. I am not sure if there is a way top do thisthe first image is the desired plot edited in slides and the second is an R plot that needs to be changed.
My current code is
ggline(ACE2data2, x = "Time", y = "Fluorescence")
labs(x = "Time (min)", y = "RFU Ex/Em 320/420nm")
theme(axis.title.x = element_text(size = 22))
theme(axis.title.y = element_text(size = 22))
facet_wrap2(~ Dilution,
nrow = 5,
ncol = 4,
axes = "all")
force_panelsizes(rows = unit(4, "cm"), cols = unit(4, "cm"))
coord_cartesian(ylim = c(0, 10000))
theme(strip.text.x = element_blank(), strip.background = element_blank())
Any help is sincerely appreciated!! A big thanks in advance :)
CodePudding user response:
As you are already using ggh4x
you could achieve your desired result via ggh4x::facetted_pos_scales
which allows to set the scale individually for each panel. Doing so you could remove the labels for the upper panel rows. To make this work you also have to set scales="free_x"
.
As you provided no example data I use some fake data for the reprex. Hence, you have to adjust the condition to filter for the upper panels:
library(ggplot2)
library(ggpubr)
library(ggh4x)
ACE2data2 <- data.frame(
Dilution = rep(1:20, each = 10),
Time = 1:10,
Fluorescence = 1:10
)
ggline(ACE2data2, x = "Time", y = "Fluorescence")
labs(x = "Time (min)", y = "RFU Ex/Em 320/420nm")
theme(axis.title.x = element_text(size = 22))
theme(axis.title.y = element_text(size = 22))
facet_wrap2(~ Dilution,
nrow = 5,
ncol = 4,
axes = "all", scales = "free_x")
force_panelsizes(rows = unit(4, "cm"), cols = unit(4, "cm"))
#coord_cartesian(ylim = c(0, 10000))
theme(strip.text.x = element_blank(), strip.background = element_blank())
facetted_pos_scales(x = list(
(Dilution > 16) ~ scale_x_continuous(),
(!Dilution > 16) ~ scale_x_continuous(labels = NULL)
))
CodePudding user response:
If your scales are fixed, the easier solution is to use remove_labels = "all"
.
Shamelessly stealing stefan's dummy data:
library(ggplot2)
library(ggpubr)
library(ggh4x)
ACE2data2 <- data.frame(
Dilution = rep(1:20, each = 10),
Time = 1:10,
Fluorescence = 1:10
)
ggline(ACE2data2, x = "Time", y = "Fluorescence")
labs(x = "Time (min)", y = "RFU Ex/Em 320/420nm")
theme(axis.title.x = element_text(size = 22))
theme(axis.title.y = element_text(size = 22))
facet_wrap2(
~ Dilution, nrow = 5, ncol = 4,
axes = "all", remove_labels = "all"
)
force_panelsizes(rows = unit(4, "cm"), cols = unit(4, "cm"))
theme(strip.text.x = element_blank(),
strip.background = element_blank())