Closed lindsayplatt closed 7 years ago
Did you try append=TRUE
?
from gsplot v0.8.0
,
par('usr')
[1] 1.0 100.0 0.6 1.4
from v0.7.1
:
par('usr')
[1] 1 100 30 70
in v0.8.0
, this chunk of code that is run after the rendering will reset par('usr')
back to what it should be for view.1.2
, which is the new behavior you are seeing (instead of leaving it w/ the last rendered usr
, as happened in v0.7.1
).
if(!is.null(view.info)){
default_view <- ifelse("view.1.2" %in% view.info$name, "view.1.2", view.info$name[1])
set_frame(views, default_view)
}
I think this code change is related to getting the legend()
call that happens next in print
?
https://github.com/USGS-R/gsplot/commit/43e27b9403489dcc842bed0eb880ee04651c2e90 @ldecicco-USGS can you weigh in?
legend
was the main reason. Also, if you added something in base R later, it would be in whatever view was last, and sometimes that was totally wrong.
For example, I know this example was fixed by adding that line:
date_vector <- seq(as.Date("2010-10-01"), as.Date("2011-09-30"), by="months")
gs <- gsplot() %>%
points(date_vector, 1:12)
gs
points(as.Date("2011-01-15"),2.5, col="blue", pch=20)
without switching to default, it didn't plot that last point
seems our backdoor solution to axes > 4 might need revising, or we might need to rethink yes/no support for axes > 4?
The backdoor solution could probably be rejiggered (defining the par or something), but we could think more about if the current total behavior in gsplot
makes sense.
I wonder if default view should be the last view instead of the first?
@lindsaycarr if reworking the previous solution:
plot2 <- gsplot() %>%
points(side=2, 1,1) %>%
points(side=4, 100, 100) %>%
points(side=6, 50,50, axes=FALSE)
par(mar=c(5,4,4,6))
plot2
plot(NA, 0, ylim = ylim(plot2, side = 6), xlim=c(0,1), axes=FALSE, ylab="", xlab="")
axis(side=4, at=seq(30,70,by=10), line=3, las=1)
would do it.
I think the issue was (at the time) that if you just added some ticks in axis=4, the limits for an empty view 1,4 wasn't getting the right limits. I think maybe now we fixed that?? Maybe we can test if taking that resetting of view out and leave it as the last view and see if the readme example works now? (then we need to figure out legend
.
I feel like though that a lot of weird behavior was fixed with that line...so let's be very careful with a change.
cool. agreed. Proposed backdoor solution ☝️
@jread-usgs that would be behavior I would expect
sorry, my github was lagging. Yes, backdoor solution that @jread-usgs provided will be good (except that it needs a par(new=TRUE)
!
The scale on new added axes seems dependent on side 2, which was not the case before.
v0.7.1 printed this:![image](https://cloud.githubusercontent.com/assets/13220910/24759279/9dc39b82-1aaa-11e7-877e-f6b7aee744c8.png)
But v0.8.0 shows this:![image](https://cloud.githubusercontent.com/assets/13220910/24759332/c89de1fa-1aaa-11e7-8aa2-8111ef0e7c9b.png)
The red circle shows where the axis is. Since the new axis is from 30-70, it shows up as a small dot because side 2 is from 0.6-1.4.