r - ggplot中的相同比例
问题描述
我想要两个尺度都等于范围,如何在 ggplot2 中做到这一点:
ggplot2 可重现的例子
mtcars %>% ggplot(aes(x = wt, y = drat)) + geom_point()
解决方案
这是一个例子:
library(tidyverse)
library(wrapr)
mtcars %.>%
ggplot(., aes(x = wt, y = drat)) +
geom_point() +
coord_cartesian(
xlim = c(min(pmin(.$wt, .$drat)), max(pmax(.$wt, .$drat))) -> sc_range,
ylim = sc_range
)
推荐阅读
- flutter - 'positions.isNotEmpty':PageController.page 在使用它构建 PageView 之前无法访问。旋转木马颤动
- python - Python seaborn.heatmap 手动定义类别
- javascript - 使用 setFocus 更改 jVectorMap 中多个区域的缩放级别
- websocket - 如何检查 Spring Websocket(Jetty) 中的 TCP 缓冲区大小?
- firebase-realtime-database - 有没有办法在没有数据库的情况下记录名字?
- javascript - 有人可以解释一下为什么“运算符优先级”适用于 javaScript 中的“||”、“&&”等逻辑运算符
- .net - VB.NET 关闭图表数据工作簿
- mysql - 如何通过ids查找Mysql(5.6版)中两行之间的差异
- json - 不要从缩小的 json 中的“值”中删除空格
- biztalk - 自动部署:两者之间的差异。BTS 2016 FP2 和 BTS2020