【发布时间】:2018-08-14 10:22:10
【问题描述】:
我正在尝试使用 ggplot2 制作图表,我将其设想为这两个图的组合:
本质上,我想要的是第一张图片在背景中,所有数据都在前面。
到目前为止我尝试了什么:
使用第一张图片作为 ggplot 的背景。
使用
+ geom_poly()或胖+ geom_segment()
但无法像我希望的那样无缝地工作。
点数据如下所示:
input2 <- read.table(
text = "rowname key variable value
1 January 2016 8233
2 February 2016 11573
3 March 2016 23016
4 April 2016 32029
5 May 2016 51280
6 June 2016 30652
7 July 2016 62877
8 August 2016 80680
9 September 2016 60807
10 October 2016 74004
11 November 2016 60995
12 December 2016 39608",
header = T,
stringsAsFactors = F)
我的情节代码如下所示:
library(ggplot2)
ggplot(input2, aes(x=key, y=value, color=variable))+
geom_point(aes(size=value)) +
scale_x_discrete(limits=c("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")) +
#annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf) +
#geom_segment(aes(x = x1, y = y1, xend = x2, yend = y2, colour = "segment"), data = grass) +
scale_colour_manual(values=c("#CC6600", "#999999", "#FFCC33")) +
ggtitle("Number of Images per month\n") +
labs(x="Month",y="Number of images", fill="Legend")
注释掉的东西是我不成功的尝试。
【问题讨论】: