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
Using the code below the figure that appears in the margin has an overly small font size. Do you know if Is this something that is a result of the data/plot, or the way that msmbstyle is doing the formatting?
# If tidyverse package not installed in RStudio, remove '#' from next line
# The read_csv comamnd is part of the Tidyverse package readr
# install.packages("tidyverse")
library(tidyverse)
# Read the data
data <- read_csv("country,number_of_species
Ecuador,96
Peru,87
Colombia,52
Bolivia,43
Venezuela,18
Argentina,7")
# Default ggplot figure style
# Note that the package is called ggplot2 but the command is 'ggplot'
ggplot(data, aes(country, number_of_species)) + # Specify x first, then y
geom_bar(stat = "identity") + # Plot type
theme_gray()
With grateful thanks.
The text was updated successfully, but these errors were encountered:
msmbstyle doesn't really influence the plots directly, it just puts in the margin whatever has been created by the code + knitr/markdown.
If you want more readable fonts plots from ggplot2 I see two option:
Use the chunk options fig.width, fig.height, dpi to modify the size of the image that is produced. The font size tends to remain static relative to the image resolution, so a high-resolution plot ends up having really small text. Conversely, choose smaller than default options (which is probably fine for a relatively small margin picture) and the text appears larger. This would get you a square image with 400px & 400px:
Use the theme elements in ggplot2 to increase the font size. For your example, the theme_grey() function has an option to set all fonts to a single value e.g.
ggplot(data, aes(country, number_of_species)) +# Specify x first, then y
geom_bar(stat="identity") +# Plot type
theme_gray(base_size=20)
You can of course combine both of these to produce smaller images to speed up loading, and also adjust the font size in ggplot.
Using the code below the figure that appears in the margin has an overly small font size. Do you know if Is this something that is a result of the data/plot, or the way that msmbstyle is doing the formatting?
With grateful thanks.
The text was updated successfully, but these errors were encountered: