我的代码在下面列出。我有非常特定的颜色,必须在工作中使用。但是,我试图在所有气泡周围留下红色的边缘。我一直无法弄清楚。我认为边缘的大小也应约为1.25pts。任何帮助都会很棒。
ggplot(data, aes(x = Date_Id,
y = Level.Of.Difficulty, size = Savings), show.legend = F) +
geom_point(aes(color = Source, alpha = 0.6)) +
geom_text(aes(label = Initiative), size = 4) +
scale_size_continuous(range = c(1, 75)) +
scale_y_discrete(limits = c("Low", "", "", "", "", "", "", "", "", "High")) +
scale_x_discrete(limits = c("","","Sep-18","","","","","","",
"Oct-18", "","","","","","",
"Nov-18", "","","","","","",
"Dec-18", "","","","","","",
"Jan-19", "","","","","","",
"Feb-19", "","","","","","",
"Mar-19", "","","","","","",
"Apr-19", "","","","","","",
"May-19", "","","","","","",
"Jun-19", "","","","","","", "Jul-19")) +
labs(x = "Date", y = "Level of Difficulty") +
ggtitle("2019 SC Major Initiatives") +
scale_alpha(guide = 'none') +
geom_vline(aes(xintercept = 33), size = 1.4) +
geom_hline(aes(yintercept = 5.5), size = 1.4,
linetype = 6) +
scale_color_manual(values = c("#008000", "#0000FF")) +
theme(plot.title = element_text(hjust = 0.5),
legend.position = c(0.035, 0.035),
legend.background = element_blank(),
legend.title = element_blank(),
legend.text = element_text(size = 12),
panel.background = element_blank(),
axis.line = element_line(color = "black")) +
guides(size = F)
我希望颜色保持不变,只是在每个气泡点添加一个红色边缘。
以下是一些示例数据:
Source,Initiative,Date,Date_Id,Month_ID,Level Of Difficulty,Savings
A,Item 1,9/1/2018,1,1,9,295210
B,Item 2,9/5/2018,2,1,5,75000
A,Item 3,9/5/2018,2,1,6.5,123731.0192
B,Item 4,9/10/2018,3,1,8.5,224669
A,Item 5,9/15/2018,4,1,2,55031.13936
B,Item 6,4/5/2019,50,8,3,3780.4376
A,Item 7,4/5/2019,51,8,7.25,300000
B,Item 8,4/10/2019,52,8,6,179959
A,Item 9,4/10/2019,52,8,9,51377.61048
B,Item 10,1/1/2019,30,5,7.5,1066667
A,Item 11,1/5/2019,31,5,6.5,1000000
B,Item 12,1/10/2019,32,5,8.5,425000
A,Item 13,1/10/2019,32,5,9.5,68112.1856
B,Item 14,1/20/2019,34,5,3,21753.416
A,Item 15,1/20/2019,34,5,8,374608
答案 0 :(得分:2)
使用其他shape
并调整stroke
并用fill
切换color
似乎可行:
ggplot(data, aes(x = Date_Id,
y = Level.Of.Difficulty, size = Savings), show.legend = F) +
geom_point(aes(fill = Source, alpha = 0.6), shape = 21, color = "red", stroke = 1.25) +
geom_text(aes(label = Initiative), size = 4) +
scale_size_continuous(range = c(1, 75)) +
scale_y_discrete(limits = c("Low", "", "", "", "", "", "", "", "", "High")) +
scale_x_discrete(limits = c("","","Sep-18","","","","","","",
"Oct-18", "","","","","","",
"Nov-18", "","","","","","",
"Dec-18", "","","","","","",
"Jan-19", "","","","","","",
"Feb-19", "","","","","","",
"Mar-19", "","","","","","",
"Apr-19", "","","","","","",
"May-19", "","","","","","",
"Jun-19", "","","","","","", "Jul-19")) +
labs(x = "Date", y = "Level of Difficulty") +
ggtitle("2019 SC Major Initiatives") +
scale_alpha(guide = 'none') +
geom_vline(aes(xintercept = 33), size = 1.4) +
geom_hline(aes(yintercept = 5.5), size = 1.4,
linetype = 6) +
scale_fill_manual(values = c("#008000", "#0000FF")) +
theme(plot.title = element_text(hjust = 0.5),
legend.position = c(0.035, 0.035),
legend.background = element_blank(),
legend.title = element_blank(),
legend.text = element_text(size = 12),
panel.background = element_blank(),
axis.line = element_line(color = "black")) +
guides(size = F)