-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Custom tick marks and borders in guide_colorbar #1530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
# create data frame for tick display | ||
breaks <- scale$get_breaks() | ||
if (length(breaks) == 0 || all(is.na(breaks))) | ||
return() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove these minor changes that aren't related to your new functionality? That makes it easier for me to review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump
#' @param ticks A logical specifying if tick marks on colorbar should be | ||
#' visible. | ||
#' @param ticks A \code{\link{element_line}} object specifying the appearance | ||
#' of the tick marks.' For backwards compatibility, a logical can also be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra '
I've made the changes - let me know if there's anything else I can do. |
|
||
...) { | ||
|
||
if (!is.null(barwidth) && !is.unit(barwidth)) barwidth <- unit(barwidth, default.unit) | ||
if (!is.null(barheight) && !is.unit(barheight)) barheight <- unit(barheight, default.unit) | ||
|
||
# if logical argument supplied to tick then use defaults | ||
if (identical(ticks, TRUE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're currently specifying the default in two places - here and above in the parameter list. I think it would be better to specify only in one place.
I'd recommend restructuring this if block to cover all cases:
if (identical(ticks, TRUE)) {
} else if (identical(ticks, FALSE)) {
} else if (inherits(ticks, "element")) {
} else {
stop("`ticks` should be ...", call. = FALSE)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, thinking about it more, shouldn't the default come from the theme system?
Closing due to apparent lack of interest |
I'd like to add my vote for this feature if interest arises again, I've been trying to do this for quite a long time. Let me know if I can be of help getting this in place |
I would like to see this feature also! |
Me too. I really hope we can use this feature! |
Would love to have it re-opened. ggplot's colorbar is doesn't seem quite right compared to colorbars from Matlab or Python. |
I also opt for this feature! White on white sucks.. |
I would really like this feature as well. It would be very useful to be able to change the color of the colorbar border and tick marks. |
+1 - This is the one thing that stops me from using ggplot for spatial viz. |
+1, same problem, white ticks in colorbars with light colors are not visible! |
HI @DanOvando @josetanago @johnbaums @srgorelik @nichtleiter @komodovaran @ko-ichi-h @PeteCowman , The best way to add your Thanks |
This effect can now be achieved, using a slightly different syntax: #2541 |
Hallelujah! This was a long time coming. Thanks to all that drove this. |
Awesome! Thank you so much for implementing this functionality @clauswilke! |
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/ |
Custom tick marks and borders in guide_colorbar
This pull request allows the user to manually change the appearance of tick marks and borders around colorbar legends. Following a discussion on stackoverflow, a feature request was raised, but there was not enough resources to implement it at the time.
The original problem is shown below. The use of white in a color ramp results in a legend which seems to disappear at the end. Additionally, the ticks marks are hard to see.
The pull request updates that allow the user to specify
element_line
objects that dictate the appearance of the legend. By using features in the pull request, we can specify black tick marks and borders to fix this issue.This is my first "real" pull request on Github, so please let me know if I'm doing anything wrong :)
EDIT: fix typo