将单位添加到地理文本标签
Add units to geomtext label
我创建了一个气泡图,想给气泡的大小贴上标签。但是,我看不出如何向标签添加单位,即不是说“228”而是让标签显示为“228 qq”
密码是:
SalesChannells <- read.csv("SalesChannelsData.csv")
View(SalesChannells)
SalesChannelsScatter <- ggplot(SalesChannells, aes(x = SalesChannel, y = NumberOfFarmers, size = TotalVolumeOfCoffee, color = TotalVolumeOfCoffee), alpha=.5) +
geom_point()
SalesChannelsScatter +
scale_size_area(max_size = 30) +
theme(legend.position = "bottom", legend.direction = "horizontal") +
labs(size = "Volume of coffee sold") +
labs(title="More coffee is sold to intermediaries than to organisations") +
expand_limits(y=c(0,100)) +
labs(x="Sales Channel", y="Number of farmers")+
geom_text(aes(label=TotalVolumeOfCoffee), size=8, color="white",hjust = 1.7)
情节如下所示:
如果可以在标签后面添加一张漂亮的卡片,那将是额外的奖励积分,该卡片是一个长方形,一端是三角形,在气泡的中心结束。到目前为止,我只能添加标准矩形,不确定如何添加点或正确定位它。
可能是这样的:
geom_text(aes(label=paste(TotalVolumeOfCoffee, "qq")), size=8, color="white", hjust = 1.7)
(未测试)
我创建了一个气泡图,想给气泡的大小贴上标签。但是,我看不出如何向标签添加单位,即不是说“228”而是让标签显示为“228 qq”
密码是:
SalesChannells <- read.csv("SalesChannelsData.csv")
View(SalesChannells)
SalesChannelsScatter <- ggplot(SalesChannells, aes(x = SalesChannel, y = NumberOfFarmers, size = TotalVolumeOfCoffee, color = TotalVolumeOfCoffee), alpha=.5) +
geom_point()
SalesChannelsScatter +
scale_size_area(max_size = 30) +
theme(legend.position = "bottom", legend.direction = "horizontal") +
labs(size = "Volume of coffee sold") +
labs(title="More coffee is sold to intermediaries than to organisations") +
expand_limits(y=c(0,100)) +
labs(x="Sales Channel", y="Number of farmers")+
geom_text(aes(label=TotalVolumeOfCoffee), size=8, color="white",hjust = 1.7)
情节如下所示:
如果可以在标签后面添加一张漂亮的卡片,那将是额外的奖励积分,该卡片是一个长方形,一端是三角形,在气泡的中心结束。到目前为止,我只能添加标准矩形,不确定如何添加点或正确定位它。
可能是这样的:
geom_text(aes(label=paste(TotalVolumeOfCoffee, "qq")), size=8, color="white", hjust = 1.7)
(未测试)