[英]Define the fill of the zoomed panel using facet_zoom in ggforce
I want to fill the zoomed panel to match the default grey of facet_zoom in ggforce.我想填充缩放面板以匹配 ggforce 中 facet_zoom 的默认灰色。
ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species)) +
geom_point() +
facet_zoom(x = Species == 'versicolor') +
theme_bw()
I want the zoomed panel also to have the grey background.我希望缩放面板也有灰色背景。 Any thoughts?有什么想法吗?
I didn't want to modify facet_zoom
and I was hoping someone might know of an elegant way to modify the color of the zoom panels like with zoom.x = element_rect(fill = "grey", color = NA), zoom.y = element_rect(fill = "grey", color = NA)
within theme
, but those only address the zoomed section of the un-zoomed panel and the callout to the zoomed panel.我不想修改facet_zoom
,我希望有人知道一种优雅的方式来修改缩放面板的颜色,比如zoom.x = element_rect(fill = "grey", color = NA), zoom.y = element_rect(fill = "grey", color = NA)
在theme
中,但那些只解决未缩放面板的缩放部分和缩放面板的标注。 I do have a more brute force way to do it using annotate
:我确实有一种更蛮力的方法来使用annotate
来做到这一点:
ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species)) +
annotate("rect", xmin = data.table(iris)[Species == 'versicolor', min(Petal.Length)] * 0.965, xmax = data.table(iris)[Species == 'versicolor', max(Petal.Length)] * 1.02, ymin = -Inf, ymax = Inf, fill="light grey", alpha=0.3) +
geom_point() +
facet_zoom(x = Species == 'versicolor') +
theme_bw()
The challenge to to find the boundaries of the x and/or y axis when they're not explicit in facet_zoom
.在facet_zoom
中不明确时找到 x 和/或 y 轴边界的挑战。 I had to hunt and peck to get them to align.我不得不打猎和啄食才能让它们对齐。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.