-
Notifications
You must be signed in to change notification settings - Fork 73
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
[FEATURE] Possible to have axis text in multiple colors? #264
Comments
Could you use |
Sorry I nuked your code somehow lol library(heatmaply)
# generate data
datMat = matrix(runif(100), nrow = 10, ncol = 10)
# try a single color
heatmaply(datMat, heatmap_layers = theme(axis.text.y = element_text(colour = "blue")), main = "A sin
gle axis text color passed using theme() works")
# try multiple colors
axisColors = rep(c("red", "black"), 5)
heatmaply(datMat, heatmap_layers = theme(axis.text.y = element_text(color = axisColors)), main = "Mu
ltiple colors passed to theme doesn't work")
library(reshape2)
# multiple colors works in ggplot2
datMelt = melt(datMat)
ggplot(datMelt, aes(x = Var1, y = Var2, fill = value)) +
geom_tile() +
theme(axis.text.y = element_text(color = c("black", "red", "black", "red", "blue"))) +
ggtitle("Multiple axis colors works for ggplot()") |
I think the short answer is no, if |
No, that was me lol. When I first read |
Ah fair dues. Turns out it doesn't really like HTML output anyway so I was pointing you in the wrong direction for github issues with HTMLwidgets. |
The only way I know how do it with library(heatmaply)
#> Loading required package: plotly
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
#> Loading required package: viridis
#> Loading required package: viridisLite
#>
#> ======================
#> Welcome to heatmaply version 1.2.1
#>
#> Type citation('heatmaply') for how to cite the package.
#> Type ?heatmaply for the main documentation.
#>
#> The github page is: https://github.com/talgalili/heatmaply/
#> Please submit your suggestions and bug-reports at: https://github.com/talgalili/heatmaply/issues
#> Or contact: <tal.galili@gmail.com>
#> ======================
library(reprex)
# generate data
datMat = matrix(runif(100), nrow = 10, ncol = 10)
# multiple colors using plot_ly() method
heatmaply(datMat) %>%
add_trace(yaxis = "y2", showscale = F) %>%
layout(yaxis = list(range = list(1, 10),
tickfont = list(color = "red"),
tickvals = as.list(1:5)),
yaxis2 = list(range = list(1, 10),
overlaying = 'y',
tickfont = list(color = "blue"),
tickvals = as.list(6:10)))
#> PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.
#> No scatter mode specifed:
#> Setting the mode to markers
#> Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
#> Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...): 'x' must be atomic Created on 2021-06-17 by the reprex package (v2.0.0) EDIT: Same scatter mode error after PhantomJS was installed. library(heatmaply)
#> Loading required package: plotly
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
#> Loading required package: viridis
#> Loading required package: viridisLite
#>
#> ======================
#> Welcome to heatmaply version 1.2.1
#>
#> Type citation('heatmaply') for how to cite the package.
#> Type ?heatmaply for the main documentation.
#>
#> The github page is: https://github.com/talgalili/heatmaply/
#> Please submit your suggestions and bug-reports at: https://github.com/talgalili/heatmaply/issues
#> Or contact: <tal.galili@gmail.com>
#> ======================
library(reprex)
# generate data
datMat = matrix(runif(100), nrow = 10, ncol = 10)
# multiple colors using plot_ly() method
heatmaply(datMat) %>%
add_trace(yaxis = "y2", showscale = F) %>%
layout(yaxis = list(range = list(1, 10),
tickfont = list(color = "red"),
tickvals = as.list(1:5)),
yaxis2 = list(range = list(1, 10),
overlaying = 'y',
tickfont = list(color = "blue"),
tickvals = as.list(6:10)))
#> No scatter mode specifed:
#> Setting the mode to markers
#> Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
#> Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...): 'x' must be atomic Created on 2021-06-17 by the reprex package (v2.0.0) |
In ggplot2 I can pass a vector of colors through theme(axis.text.x), and while it gives the warning
it still works. I see this warning when passing the ggplot2 theme axis text colors through
heatmap_layers
but it doesn't seem to change the colors. A single color passed this way works.Is this possible?
Thanks!
The text was updated successfully, but these errors were encountered: