如何使用辅助y轴创建叠加图?

时间:2015-11-17 16:08:01

标签: r plot overlay

我用ggplot2为初级制作创建了一个情节 使用此代码

ggplot(x, aes(x = pp.section, y = pp.depth*-1, z= pp.temp, colour = pp.pp_sqm_gr)) +    
geom_point()+
stat_contour(z=pp.temp)+
scale_colour_gradient2("PP [mg C/m²]", low="white", high=muted("green"), limits=c(0,200))+
labs(x = "section", y = "depth [m]" , title= "PP (12h)")+
theme_bw(base_size = 12, base_family = "")+
theme(panel.background = element_rect(fill = "grey"), 
    panel.grid.major = element_line(colour = "white", size=0), 
    panel.grid.minor = element_line(colour="grey"),
    axis.text = element_text(size=10),
    axis.title = element_text(size=13),
    title = element_text(size=11))

Primary Production

我想做什么:创建一个带有辅助y轴的叠加图,用于温度。温度应显示为水平轮廓线。

由于原始数据框非常大,我举个例子:

df< - data.frame(pp.section,pp.depth,pp.chla,pp.temp,pp.pp_sqm_gr)

pp.section   pp.depth   pp.chla   pp.temp   pp.pp_sqm_gr
   1            3       3.5         18.0       26.8
   1            10      5.5         17.8       56.4
   1            15      20.9        17.0       150.4
   1            20      4.3         16.0       90.8 
   1            25      1.2         16.1       66.9
   2            30      1.0         16.2       13.1
   2            23      2.2         16.4       20.8
   2            14      23.1        17.1       117.9
   2            8       11.9        17.9       51.4
   3            5       6.8         17.9       22.6
   3            11      12.0        17.2       167.1
   3            20      5.5         16.2       74.2
   3            25      6.7         16.1       62.1

到目前为止,我尝试了ggplot geom_contour(),stat_contour()和geom_line()。 非常感谢!

0 个答案:

没有答案
相关问题