You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Indrajeet! Sorry to bother you.
I've been using extensively your package and now I have a quick question that is related to having a scale Y with breaks.
Assume I have the following code (from the gapminder package, with the life expectancy of one year artificially increased to simulate the need for a break in the Y axis):
set.seed(123)
library(ggstatsplot)
## let's split the data frame and create a list by years of interest
year_list <- gapminder::gapminder %>%
dplyr::filter(year %in% c(1967, 1987, 2007), continent != "Oceania") %>%
split(f = .$year, drop = TRUE)
year_list$`1987` = year_list$`1987` %>% #Artificially increase the life expectancy to make the need for a break in Y axis
mutate(lifeExp = lifeExp+100)
ggplot.component = list(scale_y_continuous(limits = c(30, 200)))
## creating a list of plots
plot_list <- purrr::pmap(
.l = list(
data = year_list,
x = "continent",
y = "lifeExp",
xlab = "Continent",
ylab = "Life expectancy",
title = list(
"Year: 1967",
"Year: 1987",
"Year: 2007"
),
ggplot.component = list(ggplot.component, ggplot.component, ggplot.component)
),
.f = ggbetweenstats
)
combine_plots(
plotlist = plot_list,
annotation.args = list(title = "Changes in life expectancy across continents (1967-2007)"),
plotgrid.args = list(ncol = 3)
)
To have a break in the Y axis I found the package ggbreak (https://cran.r-project.org/web/packages/ggbreak/vignettes/ggbreak.html) that should easily do the job via the scale_y_break function. But it is incompatible with functions that arrange multiple plots (see FAQs at the bottom of the link).
Plus, If I try to run the following:
plot_list$`1987` + scale_y_break(c(50,120))
I get the following error:
Error in italic("F") : italic supports only flextable objects.
I am aware I am asking something about the ggbreak package but I was wondering if you could help me out trying to have a plot which combines multiple plots, has uniform Y axis and has a break in the Y axis to help visualise the data in the plot in a proper way (maybe there is a simpler way that does not require ggbreak?)
Thanks a lot
Luca
The text was updated successfully, but these errors were encountered:
Thanks. I can reproduce. Need to dig a bit deeper as to why {ggbreak} can't find the plotmath functions.
library(ggstatsplot)
library(ggbreak)
set.seed(123)
ggbetweenstats(
data=iris,
x=Species,
y=Sepal.Length,
ggplot.component=list(scale_y_break(c(5, 7)))
)
#> Error in italic("F"): could not find function "italic"
Hi Indrajeet! Sorry to bother you.
I've been using extensively your package and now I have a quick question that is related to having a scale Y with breaks.
Assume I have the following code (from the gapminder package, with the life expectancy of one year artificially increased to simulate the need for a break in the Y axis):
To have a break in the Y axis I found the package
ggbreak
(https://cran.r-project.org/web/packages/ggbreak/vignettes/ggbreak.html) that should easily do the job via thescale_y_break
function. But it is incompatible with functions that arrange multiple plots (see FAQs at the bottom of the link).Plus, If I try to run the following:
I get the following error:
Error in italic("F") : italic supports only flextable objects.
I am aware I am asking something about the ggbreak package but I was wondering if you could help me out trying to have a plot which combines multiple plots, has uniform Y axis and has a break in the Y axis to help visualise the data in the plot in a proper way (maybe there is a simpler way that does not require
ggbreak
?)Thanks a lot
Luca
The text was updated successfully, but these errors were encountered: