Skip to content

Commit

Permalink
Fix addPolygon when observation.based = TRUE
Browse files Browse the repository at this point in the history
The code was always using the POSIXct index for the 'x' coordinates.
Use the get_xcoords() function to get the coordinates in the correct
units.

Fixes #403.
  • Loading branch information
joshuaulrich committed Jul 24, 2023
1 parent a2c7520 commit 48cadd6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,10 @@ addPolygon <- function(x, y=NULL, main="", on=NA, col=NULL, ...){
# NAs in the coordinates break the polygon which is not the behavior we want
ta.y <- na.omit(ta.adj[,-1])

n <- NROW(ta.y)
# x coordinates
xx <- .index(ta.y)[c(1,1:n,n:1)]
n <- seq_len(NROW(ta.y))
xx <- x$get_xcoords(ta.y)[c(1, n, rev(n))]

# y coordinates upper and lower
# assume first column is upper and second column is lower y coords for
# initial prototype
Expand Down

0 comments on commit 48cadd6

Please sign in to comment.