【问题标题】:Same scales in ggplotggplot中的相同比例
【发布时间】:2019-01-08 11:50:48
【问题描述】:

我想要两个比例都等于范围,如何在ggplot2中做到这一点:

ggplot2 可重现示例

mtcars %>% ggplot(aes(x = wt, y = drat)) + geom_point()

【问题讨论】:

  • 试试ylimxlim
  • 不强制使用 ylim 和 xlim

标签: r ggplot2


【解决方案1】:

这是一个例子:

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
  )

【讨论】:

    猜你喜欢
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-27
    • 2018-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多