Comments (3)
Thanks for the report! I agree with you that his behaviour is suboptimal but I don't have a quick fix for this.
As a workaround, you might consider providing the transformed scale to facetted_pos_scales()
as well, though that'd throw a (harmless) warning.
library(ggh4x)
#> Loading required package: ggplot2
library(ggplot2)
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(colour = Species)) +
geom_text(aes(label = Species)) +
facet_grid(rows = vars(Species), scales = "free_y") +
facetted_pos_scales(y = list(
ggplot2::scale_y_continuous(expand = ggplot2::expansion()),
ggplot2::scale_y_continuous(expand = ggplot2::expansion()),
ggplot2::scale_y_continuous(expand = ggplot2::expansion())
), x = scale_x_reverse())
#> Warning: Attempting to add facetted x scales, while x scales are not free.
#> ℹ Try adding `scales = "free_x"` to the facet.
Created on 2023-11-23 with reprex v2.0.2
from ggh4x.
Thank you for your response. That sounds like a good workaround. I can check if the user has provided an axis scale and then add it into the facetted_pos_scales
for further processing. I'll try.
from ggh4x.
This works well, the axis of both bottom and left annotation has been transformed. Thanks for your help
library(ggplot2)
library(ComplexHeatmap)
library(eheat)
set.seed(123)
nr1 <- 4
nr2 <- 8
nr3 <- 6
nr <- nr1 + nr2 + nr3
nc1 <- 6
nc2 <- 8
nc3 <- 10
nc <- nc1 + nc2 + nc3
mat <- cbind(
rbind(
matrix(rnorm(nr1 * nc1, mean = 1, sd = 0.5), nr = nr1),
matrix(rnorm(nr2 * nc1, mean = 0, sd = 0.5), nr = nr2),
matrix(rnorm(nr3 * nc1, mean = 0, sd = 0.5), nr = nr3)
),
rbind(
matrix(rnorm(nr1 * nc2, mean = 0, sd = 0.5), nr = nr1),
matrix(rnorm(nr2 * nc2, mean = 1, sd = 0.5), nr = nr2),
matrix(rnorm(nr3 * nc2, mean = 0, sd = 0.5), nr = nr3)
),
rbind(
matrix(rnorm(nr1 * nc3, mean = 0.5, sd = 0.5), nr = nr1),
matrix(rnorm(nr2 * nc3, mean = 0.5, sd = 0.5), nr = nr2),
matrix(rnorm(nr3 * nc3, mean = 1, sd = 0.5), nr = nr3)
)
)
mat <- mat[sample(nr, nr), sample(nc, nc)] # random shuffle rows and columns
rownames(mat) <- paste0("row", seq_len(nr))
colnames(mat) <- paste0("column", seq_len(nc))
small_mat <- mat[1:9, 1:9]
anno_data <- sample(1:10, nrow(small_mat))
# library(eheat)
draw(ggheat(small_mat,
top_annotation = HeatmapAnnotation(
foo = gganno(
matrix = anno_data,
function(p) {
p + aes(y = V1) + geom_text(aes(label = .index))
},
which = "column", height = unit(2, "cm")
), which = "column"
),
bottom_annotation = HeatmapAnnotation(
foo = gganno(
function(p) {
p + aes(y = V1) +
geom_text(aes(label = .index)) +
scale_y_continuous(limits = rev)
},
matrix = anno_data,
which = "column", height = unit(2, "cm")
),
which = "column"
),
right_annotation = HeatmapAnnotation(
foo = gganno(
function(p) {
p + aes(x = V1) +
geom_text(aes(label = .index))
},
matrix = anno_data,
which = "row", width = unit(3, "cm")
),
which = "row"
),
left_annotation = HeatmapAnnotation(
foo = gganno(
function(p) {
p + aes(x = V1) +
geom_text(aes(label = .index)) +
scale_x_continuous(limits = rev)
},
matrix = anno_data,
which = "row", width = unit(3, "cm")
),
which = "row"
),
row_km = 2L, column_km = 2L,
), merge_legends = TRUE)
from ggh4x.
Related Issues (20)
- Release ggh4x 0.2.7
- facet_nested have a different behaviour as compare to facet_grid when combining character and numeric HOT 2
- facet_wrap2 adding wrong x axis labels HOT 3
- Facet size = "variable" not working? HOT 2
- Release ggh4x 0.2.8
- match facet data with ggbarplot HOT 4
- Missing data prevents setting up secondary y-axis scale in help_sec_range and help_sec_max HOT 1
- Ggplotly will move x-axis back to default position HOT 1
- Add tag_facet function? HOT 5
- Error when facetting and using `ggtext` HOT 3
- geom_rectmargin won't work bug with fill_alpha HOT 3
- ggtext::element_markdown not working with ggh4x_0.2.8 HOT 3
- Remove x-axis labels with independent = "x" if they are identical HOT 4
- Add compatibility with ggtext::element_markdown() HOT 1
- Error in check_object(cols, is_quosures, "a {.fn vars} specification" HOT 3
- facet_grid with remove_labels removes labels but leaves the space between the panels HOT 2
- `guide_stringlegend()` throws `Error in get_layer_key(...) : argument "data" is missing, no default` HOT 4
- S3 guide system deprecated in ggplot2 3.5.0 HOT 2
- Compatibility with ggtext::element_markdown() issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggh4x.