Closed lindsayplatt closed 7 years ago
In print, in the side for loop we don't want to set old.par <- par(x[[side.name]]$par)
. This should be done in two steps, or par() should return the old par before it was modified.
I would like to be able to log each side separately, but that pops up with warnings currently. This should log the right axis, but not the left. I think it might be related to this issue.
gs <- gsplot() %>%
axis(side=4) %>%
view(side=2, ylim=c(1,100)) %>%
view(side=4, ylim=c(1,100), log='y')
Warning messages:
1: In doTryCatch(return(expr), name, parentenv, handler) :
nonfinite axis limits [GScale(-inf,0,2, .); log=1]
2: In doTryCatch(return(expr), name, parentenv, handler) :
nonfinite axis limits [GScale(-inf,0,2, .); log=1]
gs
Warning message:
In plot.window(xlim = lim(object, side), ylim = lim(object, side), :
nonfinite axis limits [GScale(-inf,0,2, .); log=1]
does it work if you have data on those sides?
Oh I guess it eliminates the warnings, but it logs both axis instead of just one. It's also not assigning the correct side as logged.
gs <- gsplot() %>%
points(1:2, c(1,100), side=2) %>%
points(3:4, c(10,1000), side=4) %>%
axis(side=4) %>%
view(side=2, ylim=c(1,100)) %>%
view(side=4, ylim=c(1,100), log='y')
gs
> logged(gs, side=1)
[1] FALSE
> logged(gs, side=2)
[1] TRUE
> logged(gs, side=4)
[1] FALSE
Reset par because that was causing an issue w/ always showing a logged axis when only one should be. Then we thought it had something to do with just view, but there are still logging issues when you don't use view.
[this works]
gs <- gsplot(xaxs='r', yaxs='r') %>%
points(1:3, c(1,10,100), side=2) %>%
points(3:5, c(10,100,1000), col="blue", side=4, log='y') %>%
axis(side=4)
gs
> logged(gs)
$side.1
[1] FALSE
$side.2
[1] FALSE
$side.4
[1] TRUE
[correct object, correct plot data, incorrect side 4 axis]
gs <- gsplot(xaxs='r', yaxs='r') %>%
points(1:3, c(1,10,100), side=2, log='y') %>%
points(3:5, c(10,100,1000), col="blue", side=4) %>%
axis(side=4)
gs
> logged(gs)
$side.1
[1] FALSE
$side.2
[1] TRUE
$side.4
[1] FALSE
This commit resets so that side 4 is not logged, but you lose the labels.
gs <- gsplot(xaxs='r', yaxs='r') %>%
points(1:3, c(1,10,100), side=2, log='y') %>%
points(3:5, c(10,100,1000), col="blue", side=4) %>%
axis(side=4)
gs
It's not something wrong with the y axes specifically, but with the second and third axes drawn. I changed the order the sides were drawn (2,4,1 instead), and it's the second and third sides drawn that are missing labels. So, this must mean it's something to do with our setting/re-setting par.
or the tmp
code in draw_axis
? Have you looked at that?
Gah - keep forgetting about that tmp stuff. Going to search now
tmp
isn't even used in the example above because there's only one call to each axis. I've compared par() right before the do.call('Axis', axis.args)
line for when side 1 is called first and then when it's called second. No difference.
so you checked to verify that the logic is correct for that tmp
code and that it isn't evaluated anyhow?
I knew it didn't get evaluated because I put a breakpoint in there and it never stopped.
OK, just want to rule it out completely - even if you put message('tmp used')
in there, it doesn't hit that? Sometimes breakpoints are goofy in this package. Alternatively, debug(draw_axis)
?
Correct, just tried that.
I reverted back trying out different commits (as far as #400) w/ the changes I made in this commit. Once I made the changes, the labels disappear so that issue is something that I introduced....now what about where I put par
calls is causing that :thinking:
.......................still stumped.
First time I call the plot, neither y-axis shows up. Second time (as long as I don't clear it), they both show up, but the axis ticks & labels for side=4 are still wrong. Seems like there is something going on with all of the par(new=TRUE)
@jread-usgs to summarize what's going on here:
log='x'
and log='y'
propagates through to the next axis call. Using view
to specify what to log has a similar effect. Setting log=''
does not do anything either. Even though set_side_log
looks like it should handle that appropriately. These graphs are trying to have side=3
logged, but side=1
not logged.
# These two graphs label both side 1 and 3 as logged
# BUT they only log the side 3 data
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1) %>%
points(c(10,100,1000), 3:5, col="blue", side=3, log='x') %>%
axis(side=3)
gs
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1, log='') %>%
points(c(10,100,1000), 3:5, col="blue", side=3, log='x') %>%
axis(side=3)
gs
# both graphs say the correct logic behind-the-scenes
logged(gs, side=1)
[1] FALSE
logged(gs, side=3)
[1] TRUE
# These two graphs label both side 1 and 3 as logged
# AND log both side 1 and 3 data
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1) %>%
points(c(10,100,1000), 3:5, col="blue", side=3) %>%
axis(side=3) %>%
view(side=3, log='x')
gs
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1) %>%
points(c(10,100,1000), 3:5, col="blue", side=3) %>%
axis(side=3) %>%
view(side=1, log='') %>%
view(side=3, log='x')
gs
# these graphs both say the exact opposite of what should be true:
logged(gs, side=1)
[1] TRUE
logged(gs, side=3)
[1] FALSE
# Correctly logged data, but no labels for any side but 1
# AND side 1 labels are logged
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1) %>%
points(c(10,100,1000), 3:5, col="blue", side=3, log='x') %>%
axis(side=3) %>%
axis(side=4)
gs
# checks out correctly again
logged(gs, side=1)
[1] FALSE
logged(gs, side=3)
[1] TRUE
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1) %>%
points(c(10,100,1000), 3:5, col="blue", side=3, log='x') %>%
axis(side=3)
gs
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1, log='') %>%
points(c(10,100,1000), 3:5, col="blue", side=3, log='x') %>%
axis(side=3)
gs
logged(gs, side=1)
[1] FALSE
logged(gs, side=3)
[1] TRUE
# side 1 data are logged, but side 3 data don't
# both axes are labeled as logged
gs <- gsplot() %>%
points(c(1,10,100), 1:3, side=1) %>%
points(c(10,100,1000), 3:5, col="blue", side=3) %>%
axis(side=3) %>%
view(side=3, log='x')
gs
# and that appears to be the behavior it expects
logged(gs, side=1)
[1] TRUE
logged(gs, side=3)
[1] FALSE
So in summary - with the changes to print.R
that are currently on my axisLogWrongSide
branch, it all seems to be working except for trying to log w/ view()
.
Ok, I believe I figured this out. The view.gsplot
function takes side
as an argument (with default c(1,2)
) BUT was passing the arg side=c(1,2)
into gather_function_info
. So if side=3
, it would always get passed in as c(1,2)
. See this commit for the change.
Good find @lindsaycarr !
Fixed with #424 !!!!
It was those pesky pars - needed to reset only the pars that pertained to the side, but not all pars.
gsplot object is correct, but plotting the wrong thing