You can change almost everything you see on your chart, but a lot of the things you may look to change are part of the "theme"
Here we are going to change some features about our title text:
ggplot(
r dataframe_name, aes(x=
r df_char1_name, y=
r df_numeric1_name) +
geom_jitter() +
geom_boxplot(aes(color =
r df_char1_name)) +
labs(title = "My first plot") +
theme(plot.title = element_text(face = "bold", size = 12))
theme1 <- ggplot(df_input, aes(!!sym(df_char1_name), !!sym(df_numeric1_name))) + geom_jitter() + geom_boxplot(aes(color = !!sym(df_char1_name))) + labs(title = "My first plot") + theme(plot.title = element_text(face = "bold", size = 12)) original_plot + theme1
Next, let's change the aesthetics of our legend box
ggplot(
r dataframe_name, aes(x=
r df_char1_name, y=
r df_numeric1_name) +
geom_jitter() +
geom_boxplot(aes(color =
r df_char1_name)) +
labs(title = "My first plot") +
theme(plot.title = element_text(face = "bold", size = 12),
legend.background = element_rect(fill="gray", colour="black"))
theme2 <- ggplot(df_input, aes(!!sym(df_char1_name), !!sym(df_numeric1_name))) + geom_jitter() + geom_boxplot(aes(color = !!sym(df_char1_name))) + labs(title = "My first plot") + theme(plot.title = element_text(face = "bold", size = 12), legend.background = element_rect(fill="gray", colour="black") ) theme1 + theme2
Finally, let's change the legend position
ggplot(
r dataframe_name, aes(x=
r df_char1_name, y=
r df_numeric1_name) +
geom_jitter() +
geom_boxplot(aes(color =
r df_char1_name)) +
labs(title = "My first plot") +
theme(plot.title = element_text(face = "bold", size = 12),
legend.background = element_rect(fill="gray", colour="black"),
legend.position = "bottom"))
theme3 <- ggplot(df_input, aes(!!sym(df_char1_name), !!sym(df_numeric1_name))) + geom_jitter() + geom_boxplot(aes(color = !!sym(df_char1_name))) + labs(title = "My first plot") + theme(plot.title = element_text(face = "bold", size = 12), legend.background = element_rect(fill="gray", colour="black"), legend.position = "bottom" ) theme2 + theme3
Pre-set themes also exist as an easy way to change the entire theme of your graph quickly. They can also be combined with custom theme settings
ggplot(
r dataframe_name, aes(x=
r df_char1_name, y=
r df_numeric1_name) +
geom_jitter() +
geom_boxplot(aes(color =
r df_char1_name)) +
labs(title = "My first plot") +
theme_minimal()
theme4 <- ggplot(df_input, aes(!!sym(df_char1_name), !!sym(df_numeric1_name))) + geom_jitter() + geom_boxplot(aes(color = !!sym(df_char1_name))) + labs(title = "My first plot") + theme_minimal() theme1 + theme4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.