Open sfd99 opened 1 week ago
Hi @sfd99
Thank you for using tidyplots!
Unlike ggplot2, tidyplots uses absolute sizes in millimeter (mm) for plot dimensions. The default plot size is 50 mm by 50 mm. This can be quite small depending on the machine you are working on.
There are several ways to address this.
In RStudio you can increase the zoom. View
> Zoom In
. Or alternatively Ctrl
+ +
. However, this will also increase the font size in RStudio.
You can increase the size of the tidyplot.
study %>%
tidyplot(x = treatment, y = score, color = treatment, width = 80, height = 80) %>%
add_mean_bar(alpha = 0.4) %>%
add_sem_errorbar() %>%
add_data_points_beeswarm()
# an alternative way
study %>%
tidyplot(x = treatment, y = score, color = treatment) %>%
add_mean_bar(alpha = 0.4) %>%
add_sem_errorbar() %>%
add_data_points_beeswarm() %>%
adjust_size(80, 80)
study %>%
tidyplot(x = treatment, y = score, color = treatment, width = NA, height = NA) %>%
add_mean_bar(alpha = 0.4) %>%
add_sem_errorbar() %>%
add_data_points_beeswarm()
# an alternative way
study %>%
tidyplot(x = treatment, y = score, color = treatment) %>%
add_mean_bar(alpha = 0.4) %>%
add_sem_errorbar() %>%
add_data_points_beeswarm() %>%
adjust_size(NA, NA)
Best Jan
Thanks, Jan. All your suggested solutions do work ok.
I like your sol: %>% adjust_size(NA, NA)...
Wish there was a default plot size setting that I could define in advance, so that all calls to tidyplot() would follow those User-defined std. plot size values...
ie: 120 by 120 for all plots...
Would that make sense? :-)
RAY
I will think about this.
For now, to achieve a consistent look across multiple plots, I would recommend to define a personal style and then apply it to your plots.
my_style <-
. %>%
adjust_colors(colors_continuous_bluepinkyellow) %>%
adjust_font(family = "mono", face = "bold") %>%
adjust_size(80, 80)
study %>%
tidyplot(x = treatment, y = score, color = treatment) %>%
add_mean_bar(alpha = 0.4) %>%
add_sem_errorbar() %>%
add_data_points_beeswarm() %>%
my_style()
study %>%
tidyplot(x = treatment, y = score, color = treatment) %>%
add_mean_dash(alpha = 0.4) %>%
add_sem_errorbar() %>%
add_data_points_beeswarm() %>%
my_style()
Best Jan
I think I have a problem related to this issue. Whenever I visualize or save a plot, I have plenty of white space in the margins of the plot, even if I set the plot size manually:
input_data %>%
tidyplot(x = time, y = area_perc, color = compound, fill = compound, dodge_width = 0) %>%
add_mean_line() %>%
add_data_points(alpha = 0.5, shape = 16) %>%
add_sem_ribbon() %>%
adjust_colors(custom_colors) %>%
adjust_x_axis_title("Time (h)") %>%
adjust_y_axis_title("Area %") %>%
adjust_legend_title(element_blank()) %>%
adjust_size(150, 100)
save_plot("./Biotransformation_plot5.png",
bg = "white",
dpi = 600,
units = "cm",
width = 15,
height = 10)
How can I remove all this blank space?
Hi @eggrandio
where do you get the white space? In your PNG file or in the RStudio Viewer Pane?
By the way, did you miss a %>%
between the adjust_size()
and save_plot()
line?
Hi,
My apologies for the mistake. I was missing the pipe. Anyways, I still get the blank space in the PNG file when I adjust the size:
study %>%
tidyplot(x = treatment, y = score, color = treatment) %>%
add_data_points() %>%
add_sem_errorbar() %>%
add_mean_dash() %>%
theme_tidyplot() %>%
save_plot("./tidyplot_test.png",
bg = "white",
dpi = 600,
units = "cm",
width = 15,
height = 10)
Gives:
It is a minor issue as I can resize them manually for presentations, etc. but it would be nice to control the size of the output when saving (and keeping the scale between text and plot).
I see. This is because width
and height
in save_plot()
refer to the device size, not the plot area size. I need to correct this in the documentation.
You need to specify the plot area size with adjust_size()
. I think this is what you are looking for.
study %>%
tidyplot(x = treatment, y = score, color = treatment) %>%
add_data_points() %>%
add_sem_errorbar() %>%
add_mean_dash() %>%
theme_tidyplot() %>%
adjust_size(150, 100) %>%
save_plot("./tidyplot_test.png",
bg = "white",
dpi = 600)
Hi Jan,
The tidyplots PKG examples are all easy to use, understand and really look great.
But, when rendered in my Rstudio Plot Panel, ALL the example plots look really small and hard to read, (... each plot has a lot of white, empty space around it...).
ie: library(tidyplots)
study %>% tidyplot(x = treatment, y = score, color = treatment) %>% add_mean_bar(alpha = 0.4) %>% add_sem_errorbar() %>% add_data_points_beeswarm()
Is there a way to enlarge the plot size in the Rstudio Plot panel? . Maybe I'm doing something wrong?...
Thanks! / Danke!
RAY San Francisco using: tidyplots PKG v: 0.1.2 ( d/l from CRAN ) Ubuntu Linux 20.04 Rstudio 2024.09.1 Build 394 ( very latest version ) R 4.4.2