Skip to content

Commit

Permalink
Changes during the meeting + fixed rescale11y
Browse files Browse the repository at this point in the history
  • Loading branch information
Knicey committed Aug 2, 2024
1 parent 66342c8 commit 33a76c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
10 changes: 5 additions & 5 deletions R/geom_segment_glyph.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ rescale01y <- function(y, yend, ylim=NULL) {
return(list(y, yend))
}

rescale11y <- function(y, yend, ylim=NULL) {
#The rescale01x function can be used here because y and yend are agnostic
y = rescale01x(y)
yend = rescale01x(yend) * -1
return(list(y,yend))
rescale11y <- function(y, yend, xlim=NULL) {
newy = 2 * (rescale01y(y, yend)[[1]] - 0.5)
newyend = 2 * (rescale01y(y, yend)[[2]] - 0.5)

return(list(newy, newyend))
}

is.rel <- function(x) inherits(x, "rel")
Expand Down
9 changes: 5 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ devtools::install_github("Knicey/stglyphs")

This is a basic example which shows you how to solve a common problem:

```{r example, eval = FALSE}
```{r example}
library(stglpyhs)
grouped <- stations |>
group_by(month, name, long, lat) |>
summarise(
avgmin = mean(tmin, na.rm = TRUE),
avgmax = mean(tmax, na.rm = TRUE)
)
) |>
ungroup()
#TODO: Accommodate for xend aesthetic (required in geom_segment)
````
```{r example, eval = FALSE}
```
```{r example}
ggplot(data = grouped) +
geom_sf(data = mainland_us, color = "white") +
ggthemes::theme_map() +
Expand Down
6 changes: 4 additions & 2 deletions vignettes/GeomSegmentGlyph.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ knitr::opts_chunk$set(

```{r setup}
library(stglpyhs)
library(dplyr)
library(ggplot2)
```

# GeomSegmentGlyph
Expand Down Expand Up @@ -90,7 +92,7 @@ ggplot(data = grouped) +
geom_point(aes(x = long, y = lat)) +
geom_segment_glyph(
x_scale = rescale11x,
y_scale = rescale11y,
y_scale = rescale01y,
width = 2,
height = 3,
aes(
Expand All @@ -111,7 +113,7 @@ ggplot(data = grouped) +
geom_point(aes(x = long, y = lat)) +
geom_segment_glyph(
x_scale = rescale11x,
y_scale = rescale11y,
y_scale = rescale01y,
global_rescale = FALSE,
width = 2,
height = 3,
Expand Down

0 comments on commit 33a76c5

Please sign in to comment.