You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Secondary axis doesn't show axis ticks or labels with coord_trans #2990
Exactly the same issue as #2072, which I take it was fixed since it is closed.
The secondary axis ticks and labels do not show up when coord_trans is present, even if using the identity transformation. The axis label ("name" parameter) does still appear.
For example, roughly taking from the examples in sec_axis:
changed the title [-]Secondary axis doesn't work with coord_trans[/-][+]Secondary axis doesn't show axis ticks or labels with coord_trans[/+]on Nov 9, 2018
It seems so. At least it predates my changes from #2796 and is present with version 3.0.0. I'll need to look into this further to be certain. Will do when I'm back at my desktop.
This problem comes from here in CoordTrans$setup_panel_params(); out is redefined so the params for the secondary axis (out$sec.range, out$sec.major, out$sec.minor, etc) are lost.
I played around with this a little on my branch containing my most recent sec.axis patch (#3040) and can confirm the misalignment is still an issue. Interestingly, it's unique to all the other misalignment issues. It seems that when coord_trans() is specified sec.axis is passed the unexpanded range -- the transformed range of the data, not the transformed range of the primary scale (as it is when no coord is specified). This leads to misalignment relative to the primary axis.
A screenshot of output from within debug(get("break_info", AxisSecondary)) to demonstrate the actual break specifications calculated:
Notably, and likely a separate bug worth flagging in its own issue, the layer_scales function runs the break_info function with the expected, expanded, range even when passed coord_trans() and returns properly aligned break values; a bug I have encountered when debugging other sec.axis issues and which can give users a false reading of the position of tick axes (as it does below):
Since this is a scale expansion issue, misalignment is fixed if one specifies expand = c(0,0) but we will likely want to dig deeper into this (and merge an appropriate coord_trans patch) once the sec.axis refactoring is complete.
Activity
[-]Secondary axis doesn't work with coord_trans[/-][+]Secondary axis doesn't show axis ticks or labels with coord_trans[/+]clauswilke commentedon Nov 9, 2018
Reprex:
Created on 2018-11-09 by the reprex package (v0.2.1)
@dpseidel Is this distinct from #2978?
dpseidel commentedon Nov 9, 2018
It seems so. At least it predates my changes from #2796 and is present with version 3.0.0. I'll need to look into this further to be certain. Will do when I'm back at my desktop.
yutannihilation commentedon Nov 12, 2018
This problem comes from here in
CoordTrans$setup_panel_params();outis redefined so the params for the secondary axis (out$sec.range,out$sec.major,out$sec.minor, etc) are lost.ggplot2/R/coord-transform.r
Lines 192 to 195 in 868fdb7
If I replace the code with below, at least the labels are shown (the locations are wrong, though).
ptoche commentedon Nov 12, 2018
If
out$sec.majorends up having length 0, then the axis is removed following the logic explained here: #2983 (comment), I guess.dpseidel commentedon Dec 16, 2018
I played around with this a little on my branch containing my most recent sec.axis patch (#3040) and can confirm the misalignment is still an issue. Interestingly, it's unique to all the other misalignment issues. It seems that when
coord_trans()is specifiedsec.axisis passed the unexpanded range -- the transformed range of the data, not the transformed range of the primary scale (as it is when no coord is specified). This leads to misalignment relative to the primary axis.A screenshot of output from within
debug(get("break_info", AxisSecondary))to demonstrate the actual break specifications calculated:Notably, and likely a separate bug worth flagging in its own issue, the
layer_scalesfunction runs thebreak_infofunction with the expected, expanded, range even when passedcoord_trans()and returns properly aligned break values; a bug I have encountered when debugging other sec.axis issues and which can give users a false reading of the position of tick axes (as it does below):Created on 2018-12-16 by the reprex package (v0.2.1)
Since this is a scale expansion issue, misalignment is fixed if one specifies
expand = c(0,0)but we will likely want to dig deeper into this (and merge an appropriate coord_trans patch) once the sec.axis refactoring is complete.thomasp85 commentedon Apr 11, 2019
@dpseidel do you have any idea how to handle this most gracefully?
dpseidel commentedon Apr 11, 2019
I'll need to look back into it. I'll plan my own private dev day this weekend to dig into this and other open axis/scale issues 👍
paleolimbot commentedon May 23, 2019
This seems related to #3338 in that
coord_trans()is handling scale expansion differently than other coords.lock commentedon Dec 28, 2019
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/