【问题标题】:Different marker with increasing size in faceting刻面尺寸增加的不同标记
【发布时间】:2020-02-13 12:07:18
【问题描述】:

在下面的示例代码中,我希望每个Grade 和我选择的size 都有不同的marker 而不是circle。现在size 是基于alphabetsequence - 我想将它提升至少两个级别,因为当前起始size(以Grade A 开头)太小了。

library(tidyverse)

DF1 = data.frame(Grade = c("A","B","C","D"), Fee = c(50, 100,80, 60), ST1 = c(0.5, 0.7, 0.67,0.60),
                 ST2 = c(0.48, 0.8, 0.697,0.77), ST3 = c(0.53, 0.58, 0.57,0.62), type = rep("Teenage",4))
DF2 = data.frame(Grade = c("A","B","C","D"), Fee = c(60, 120,90, 70), ST1 = c(0.55, 0.73, 0.65,0.70),
                 ST2 = c(0.58, 0.82, 0.73,0.75), ST3 = c(0.55, 0.52, 0.58,0.62), type = rep("Overage",4))

DFPlot_1 = gather(data = DF1, key = "Variable", value = "Value", -Fee, -Grade, -type)
DFPlot_2 = gather(data = DF2, key = "Variable", value = "Value", -Fee, -Grade, -type)

DF =rbind(DFPlot_1,DFPlot_2)
ggplot(data = DF, aes(x= Fee, color = Grade, size = Grade))+
  geom_point(aes(y = Value))+ facet_grid(type ~ Variable)

这是我在运行上述代码时得到的Figure - 请参阅尺寸(A is almost non-visibile)。我想增加尺寸,但从更高的水平开始。

【问题讨论】:

  • 谢谢你,这帮了我很大的忙,解决了我的问题

标签: r ggplot2 size marker facet-grid


【解决方案1】:

如上所述,您想使用scale_size_manual。您有几种方法来调整大小(阅读文档),但适合您的情况的示例是:

ggplot(data = DF, aes(x= Fee, color = Grade, size = Grade))+
  geom_point(aes(y = Value))+ facet_grid(type ~ Variable) + 
  scale_size_manual(values = c(4,5,6,7))

【讨论】:

  • 谢谢。我实际上使用了@zx8754 提供的建议,但感谢您的努力。
猜你喜欢
  • 2015-01-27
  • 2020-12-26
  • 1970-01-01
  • 2019-08-31
  • 2018-05-21
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
相关资源
最近更新 更多