[英]How to create legend in faceted box plot on ggplot 2?
我如何摆脱所有重叠的 x 轴标签,而是创建一个图例并按颜色过滤?
library(ggplot2)
#Load in the dataset
broadband = read.csv("broadbanddata.csv")
#Box plot
ggplot(broadband) + geom_boxplot(aes(x = rsp, y = All.hour.trimmed.mean.latency)) +
labs(title="Figure 1: Average internet speed", x="Type of technology", y="Average Latency in a Day")+
facet_wrap(~technology)
尝试这个:
library(ggplot2)
#Load in the dataset
broadband = read.csv("broadbanddata.csv")
#Box plot
ggplot(broadband) + geom_boxplot(aes(x = rsp,
y = All.hour.trimmed.mean.latency,
fill = rsp)) +
labs(title="Figure 1: Average internet speed",
x="Type of technology",
y="Average Latency in a Day",
fill = "Average Latency in a Day")+
theme(axis.text.x = element_blank())+
facet_wrap(~technology)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.