-
Notifications
You must be signed in to change notification settings - Fork 634
Updates to better support dendrograms #818
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
base: master
Are you sure you want to change the base?
Changes from 8 commits
a6663c4
208eed4
9489610
4dcdebb
10936b4
f7cce29
7862f00
3e63f3c
16d097b
dac04d2
180fcfd
183b39f
88110c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,29 @@ to_basic.GeomRect <- function(data, prestats_data, layout, params, p, ...) { | |
cbind(x = xmax, y = ymax, others), | ||
cbind(x = xmax, y = ymin, others)) | ||
}) | ||
if (inherits(p$coordinates, "CoordFlip")) { | ||
dat <- with(data, { | ||
rbind(cbind(x = ifelse(xmin == -Inf, layout$y_min, xmin), | ||
y = ifelse(ymin == -Inf, layout$x_min, ymin), others), | ||
cbind(x = ifelse(xmin == -Inf, layout$y_min, xmin), | ||
y = ifelse(ymax == Inf, layout$x_max, ymax), others), | ||
cbind(x = ifelse(xmax == Inf, layout$y_max, xmax), | ||
y = ifelse(ymax == Inf, layout$x_max, ymax), others), | ||
cbind(x = ifelse(xmax == Inf, layout$y_max, xmax), | ||
y = ifelse(ymin == -Inf, layout$x_min, ymin), others)) | ||
}) | ||
} else { | ||
dat <- with(data, { | ||
rbind(cbind(x = ifelse(xmin == -Inf, layout$x_min, xmin), | ||
y = ifelse(ymin == -Inf, layout$y_min, ymin), others), | ||
cbind(x = ifelse(xmin == -Inf, layout$x_min, xmin), | ||
y = ifelse(ymax == Inf, layout$y_max, ymax), others), | ||
cbind(x = ifelse(xmax == Inf, layout$x_max, xmax), | ||
y = ifelse(ymax == Inf, layout$y_max, ymax), others), | ||
cbind(x = ifelse(xmax == Inf, layout$x_max, xmax), | ||
y = ifelse(ymin == -Inf, layout$y_min, ymin), others)) | ||
}) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a lot of redundant code... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I've simplified things a bit. |
||
prefix_class(dat, c("GeomPolygon", "GeomRect")) | ||
} | ||
|
||
|
@@ -603,10 +626,21 @@ geom2trace.GeomBoxplot <- function(data, params, p) { | |
|
||
#' @export | ||
geom2trace.GeomText <- function(data, params, p) { | ||
text <- as.character(data[["label"]]) | ||
text <- ifelse( | ||
grepl("bold", data[["fontface"]]), | ||
paste0("<b>", text, "</b>"), | ||
text | ||
) | ||
text <- ifelse( | ||
grepl("italic", data[["fontface"]]), | ||
paste0("<i>", text, "</i>"), | ||
text | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer if this was done with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, yea, but in that case I prefer something like:
|
||
compact(list( | ||
x = data[["x"]], | ||
y = data[["y"]], | ||
text = data[["label"]], | ||
text = text, | ||
key = data[["key"]], | ||
frame = data[["frame"]], | ||
ids = data[["ids"]], | ||
|
@@ -618,6 +652,14 @@ geom2trace.GeomText <- function(data, params, p) { | |
aes2plotly(data, params, "alpha") | ||
) | ||
), | ||
textposition = paste0( | ||
ifelse(data[["vjust"]] < 0.5, "top ", | ||
ifelse(data[["vjust"]] > 0.5, "bottom ", "") | ||
), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the trailing whitespace be removed here (e.g., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, nevermind. I see why it's done this why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should default to |
||
ifelse(data[["hjust"]] < 0.5, "right", | ||
ifelse(data[["vjust"]] > 0.5, "left", "center") | ||
) | ||
), | ||
type = "scatter", | ||
mode = "text", | ||
hoveron = hover_on(data) | ||
|
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.
I see this as potentially dangerous -- a scale without a guide doesn't necessarily mean it doesn't exist.
I would prefer to instead set
layout.showlegend
toFALSE
for discrete scales and remove the colorbar for continuous ones.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.
How about instead handling the discrete scale by updating this line to something like
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.
That won't work either for similar reasons
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.
I made one more attempt, hopefully we're close. Thanks.