Skip to content

Commit

Permalink
Merge pull request #246 from sstevens2/patch-7
Browse files Browse the repository at this point in the history
Changing ggtitle function to use labs arg
  • Loading branch information
naupaka authored Dec 13, 2023
2 parents 6e0f0bf + c9b0dff commit c8c95ca
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions episodes/06-data-visualization.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ ggplot(data = variants, aes(x = POS, y = DP, color = sample_id)) +
y = "Read Depth (DP)")
```

To add a *main* title to the plot, we use [`ggtitle()`](https://ggplot2.tidyverse.org/reference/labs.html):
To add a *main* title to the plot, we use [the title argument for the `labs()` function](https://ggplot2.tidyverse.org/reference/labs.html):

```{r add-main-title, purl=FALSE}
ggplot(data = variants, aes(x = POS, y = DP, color = sample_id)) +
geom_point(alpha = 0.5) +
labs(x = "Base Pair Position",
y = "Read Depth (DP)") +
ggtitle("Read Depth vs. Position")
y = "Read Depth (DP)",
title = "Read Depth vs. Position")
```

Now the figure is complete and ready to be exported and saved to a file. This can be achieved easily using [`ggsave()`](https://ggplot2.tidyverse.org/reference/ggsave.html), which can write, by default, the most recent generated figure into different formats (e.g., `jpeg`, `png`, `pdf`) according to the file extension. So, for example, to create a pdf version of the above figure with a dimension of $6\times4$ inches:
Expand Down Expand Up @@ -262,8 +262,8 @@ To further customize the plot, we can change the default font format:
ggplot(data = variants, aes(x = POS, y = DP, color = sample_id)) +
geom_point(alpha = 0.5) +
labs(x = "Base Pair Position",
y = "Read Depth (DP)") +
ggtitle("Read Depth vs. Position") +
y = "Read Depth (DP)",
title = "Read Depth vs. Position") +
theme(text = element_text(family = "Bookman"))
```

Expand Down

0 comments on commit c8c95ca

Please sign in to comment.