Closed joshwlambert closed 8 months ago
The resolution recommended by sites like Adobe for printed images is 300 dpi because they maintain good quality without making the images too heavy, and the dimensions depend on the desired size. For example, an image of 15cm x 10cm has a size of 1772 px x 1181 px. On the other hand, it seems to me that it is difficult to define a standard size for reports and PowerPoint slides, as this depends entirely on the purpose of the package or the person who is developing the presentation. However, I consider that generating the outputs in SVG format allows you to rescale the images without losing quality or information. Finally, I think that for the vignettes,it would be good that the size of the images is according to the size of the text margins in the vignettes. This way, a constant flow of margins is maintained, and it is easier to visualize the information presented in the image.
However, I consider that generating the outputs in SVG format allows you to rescale the images without losing quality or information.
This is true from a technical point of view but it's still a bit challenging and generally preferable to export images directly with the correct size. That may lead to incorrect font & element size after scaling, or clipping of text.
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
labs(title = "My beautiful ggplot2 plot with a long title!")
ggsave("myplot.svg", width = 6, height = 4)
ggsave("myplot_large.svg", width = 12, height = 8)
ggsave("myplot_small.svg", width = 3, height = 2)
This was suggested to be a data object stored in the {tracetheme} package (e.g. sysdata) which could be used by packages loading {tracetheme} as part of vignettes, reports or training material, to provide dimensions and resolution.
I don't know how practical it would be for users and how much it would be used but it would probably be useful internally in vignettes. A DRY-er approach would be to set the default plot size once in the global knitr options:
knitr::opt_chunk$set(
fig.width = tracetheme::vignette_dim$vignette_width,
fig.height = tracetheme::vignette_dim$vignette_height
)
@joshwlambert, a first PR for this would be great so we can move forward on this project. Thanks!
PR #9 now open for addressing this issue.
Based on issue #7 presented by @Degoot-AM I implemented the following theme, in which I increased the font size to improve the readability of these but kept what he presented in his comment.
theme_trace <- function() {
theme_minimal() +
theme(
plot.background = element_rect(fill = "white"),
plot.title = element_text(size = 16, face = "bold"),
axis.title = element_text(size = 14, face = "bold"),
axis.text.x = element_text(size = 12, angle = 0),
axis.text.y = element_text(size = 12, angle = 0),
axis.line = element_line(color = "black", size = 0.5),
axis.line.x = element_line(color = "black", size = 0.5),
axis.line.y = element_line(color = "black", size = 0.5),
panel.grid.major = element_line(color = "grey", size = 0.05),
panel.grid.minor = element_line(color = "grey", size = 0.05)
)
}
I made the following visualization and saved the graphics with the following height-to-width ratio. It seems to me that in this way, the font size and axes do not lose visibility, and it is possible to read them even after scaling.
p <- ggplot(economics, aes(date, unemploy)) +
geom_line() +
ggtitle("Economics Data") +
theme_trace()
ggsave("grafico.svg", plot = p, width = 7, height = 5, units = "in")
p <- ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
ggtitle("Motor Trends Data") +
theme_trace()
ggsave("grafico1.svg", plot = p, width = 7, height = 5, units = "in")
p <- ggplot(mpg, aes(class)) +
geom_bar() +
ggtitle("Fuel Economy Data")+
theme_trace()
ggsave("grafico2.svg", plot = p, width = 7, height = 5, units = "in")
I don't know what you think about it.
Thanks for exploring different options @Juanmontenegro99! This is a good reminder that the theme, and in particular the font size, needs to be evaluated in the context of the plot sizes we choose.
Both of you converged to similar options:
Let's do a very quick poll on slack, requesting answers by the end of week, to get everyone's preference.
Let it be 7.5 .....! Just to make @Juanmontenegro99 & @joshwlambert happy.
Fixed by #9.
This issue is to discuss how to easily allow image size defaults for Epiverse-TRACE plots.
In the Visualisation task and finish group meeting two, it was discussed whether it would be beneficial to have a standard size for outputs such as:
This was suggested to be a data object stored in the {tracetheme} package (e.g. sysdata) which could be used by packages loading {tracetheme} as part of vignettes, reports or training material, to provide dimensions and resolution.
Pseudo-codeish examples:
For a powerpoint
In a vignette:
Please comment with proposed methods of standardising image sizes for the output types listed above and others not mentioned. Please also propose default dimensions for each of the output types.