刻面尺寸增加的不同标记
Different marker with increasing size in faceting
在我下面的示例代码中,我希望只对每个 Grade
和我选择的 size
使用不同的 marker
而不是 circle
。现在 size
是基于 alphabet
的 sequence
- 我想将它提升至少两个级别作为当前起始 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)
。我想增加尺寸,但从更高的级别开始。
如上所述您要使用 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))
在我下面的示例代码中,我希望只对每个 Grade
和我选择的 size
使用不同的 marker
而不是 circle
。现在 size
是基于 alphabet
的 sequence
- 我想将它提升至少两个级别作为当前起始 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)
。我想增加尺寸,但从更高的级别开始。
如上所述您要使用 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))