Skip to content

Commit

Permalink
90 degree rotate_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jbengler committed Jul 5, 2024
1 parent d2a8821 commit e4939f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions R/adjust.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ ff_adjust_axis <- function(axis) {

# Rotate labels
if (rotate_labels == TRUE) rotate_labels <- 45
if (is.numeric(rotate_labels)) {
if (is.numeric(rotate_labels) && rotate_labels != 0) {
if (rotate_labels >= 90) vjust <- 0.5 else vjust <- 1
if (axis == "x")
plot <- plot + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = rotate_labels, hjust=1))
plot <- plot + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = rotate_labels, hjust = 1, vjust = vjust))
if (axis == "y")
plot <- plot + ggplot2::theme(axis.text.y = ggplot2::element_text(angle = rotate_labels, hjust=1))
plot <- plot + ggplot2::theme(axis.text.y = ggplot2::element_text(angle = rotate_labels, hjust = vjust, vjust = 1))
}

# Adjust limits
Expand Down
2 changes: 1 addition & 1 deletion vignettes/articles/Visualizing-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ animals %>%
add_data_points(shape = 1)
```

However, data points can also be used when plotting a _discrete variable_ like `treatment` against a _continuous variable_ like `score`.
However, data points can also be used to plot a _discrete variable_ against a _continuous variable_.

```{r}
study %>%
Expand Down

0 comments on commit e4939f3

Please sign in to comment.