Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to fix #5325, in particular through #5325 (comment).
Briefly, it adds a new axis guide,
guide_axis_logticks()
that draws ticks at log10-spaced positions.In comparison to
annotation_logticks()
:?annotation_logticks
says: "These tick marks probably make sense only for base 10.", which I agree with.clip = "off"
when outside. Of course, can do equivalent ofannotation_logticks(outside = FALSE)
by setting negative tick lengths.In comparison with
guide_axis()
:key
is used for the labels. The ticks get their own 'shadow'-key.axis.ticks.{position}.{aes}
theme setting, so no tick uses theaxis.minor.ticks.{position}.{aes}
setting.Why WIP?
annotation_logticks()
as superseded?guide_axis()
#5410 gets merged, we may think about providing a custombreaks
and/orlabels
argument.A bunch of demonstrations; ticks are placed in non-transformed, original data ranges. The label placement shows that
guide_axis_logticks()
does not intervene with that part of the guide and takes these verbatim from the scale.Of course, these ticks start to make more sense with a log transformation:
Tick lengths are set in the guide. If not a
<unit>
they are interpreted as relative to the theme's tick length setting.By default, the ticks are placed 1 order of magnitude outside the limits. To clip these to the actual limits rather than the expanded limits, you can set
expanded = FALSE
.When a user has manually transformed their data, the scale doesn't know about this so the ticks would be off. To intervene, one can set
prescale_base
to calculate appropriate ticks.Because ticks are placed in original data-space, this works naturally with compound transformations, like the reverse log10 transform.
When the data include 0 or negative numbers, the ticks are mirrored around 0.
The reason for this is as follows:
Of course, some decision then has to be made where near 0 one should stop drawing ticks, as otherwise one would end up with an infinite amount of ticks. The default is
0.1
but the user can control this too.Just to show that I'm not cheating this mirroring by seeing if the scale name is
"pseudo-log"
, we can do the same with custom transformations:Created on 2023-10-28 with reprex v2.0.2