ggplot2中的美学映射温度数据

时间:2017-12-02 19:24:00

标签: r ggplot2 aes

我对r很新,我想我只是错过了一些非常简单的事情。至少我希望。我正在尝试使用aes中的ggplot2按网站绘制温度变化。但是,当我运行代码时,图表中没有数据正在上升。这是我正在使用的代码。 我的数据称为dissx=ordery=Tempdiff

tempplot<-ggplot(data = diss,mapping = 
    aes(order,Tempdiff))+geom_segment(data = diss , mapping = 
    aes(x=order,y=Tempdiff, xend=order, yend=Tempdiff, color="red"))
plot(tempplot)

当我运行代码并且图形拉起时没有错误,它只是空的。我的代码中有什么东西我不知道是删除数据还是我错过了实际添加数据的关键代码?

如果我遗漏了回答这个问题所必需的内容,我很乐意添加更多内容。提前谢谢!

增加:

> dput(diss)
structure(list(Paper = c(1L, 2L, 3L, 4L, 5L, 6L, 6L, 6L, 6L, 
7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 10L, 10L, 10L), Specimen = structure(c(4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 2L, 
2L, 4L, 4L, 4L), .Label = c("", "Ochotona_collaris", "Ochotona_curzoniae", 
"Ochotona_principes"), class = "factor"), Site = structure(c(15L, 
16L, 6L, 10L, 3L, 7L, 14L, 18L, 8L, 17L, 17L, 17L, 17L, 11L, 
2L, 13L, 9L, 9L, 4L, 12L, 5L), .Label = c("", "Arapaho_Basin", 
"Bodi ", "Bouldera_Pass", "Calf_Robe", "Columbia_River_Gorge", 
"Craters_of_Moon", "Grand_Teton ", "Kluane_Lake", "Lava_Butte Flow_OR", 
"Loveland_Pass", "Mad_Wolf", "Niwat_Ridge", "Rocky_Mt", "South_Couliee", 
"Sugar_Hill_Modoc", "Tibet_China", "Yellowstone"), class = "factor"), 
    elevation = c(2565L, 2203L, 316L, 1200L, 2600L, 1700L, 3462L, 
    2424L, 2815L, 3846L, 3846L, 3846L, 3846L, 3654L, 3878L, 3744L, 
    2000L, 2000L, 2133L, 2026L, 2004L), yr1 = c(2012L, 1894L, 
    2011L, 2011L, 1972L, 2010L, 2010L, 2010L, 2010L, 2005L, 2006L, 
    2007L, 2008L, 1981L, 1981L, 1981L, 1999L, 2003L, 2007L, 2008L, 
    2008L), yr1pop = c(9L, 4L, 9L, 9L, 48L, 55L, 39L, 71L, 54L, 
    182L, 219L, 223L, 231L, 6L, 4L, 10L, 5L, 3L, 2L, 3L, 7L), 
    yr1temp = c(25, 30, 32.1, 20, 20, 27.1, 15.4, 21.2, 18, 11, 
    13, 14, 12.5, 24.7, 26.5, 28.4, 12, 17, 20, 20, 20), yr2 = c(2013L, 
    1910L, 2012L, 2012L, 2006L, 2011L, 2011L, 2011L, 2011L, 2006L, 
    2007L, 2008L, 2009L, 1983L, 1983L, 1983L, 2002L, 2006L, 2009L, 
    2009L, 2009L), yr2temp = c(26, 31.4, 33.2, 17.1, 24.76, 30.7, 
    18.2, 22, 20, 13, 14, 12.5, 13, 26.1, 27.3, 28.3, 15, 16, 
    20, 20, 10), yr2pop = c(9L, 2L, 9L, 7L, 4L, 40L, 20L, 37L, 
    37L, 219L, 223L, 231L, 214L, 5L, 4L, 8L, 4L, 2L, 2L, 7L, 
    2L), delta_temp = c(1, 1.4, 1.1, 2.9, 4.76, 3.6, 2.8, 0.8, 
    2, 2, 1, 1.5, 0.5, 1.4, 0.8, 0.1, 3, 1, 0, 0, 10), avg_temp = c(25.5, 
    30.7, 32.65, 18.55, 44.76, 28.9, 16.8, 21.6, 19, 12, 13.5, 
    13.25, 12.75, 25.4, 26.9, 28.35, 13, 16.5, 20, 20, 15), delta_pop = c(0L, 
    2L, 0L, 2L, 44L, 15L, 19L, 34L, 17L, 37L, 4L, 8L, 17L, 1L, 
    0L, 2L, 1L, 1L, 0L, 4L, 5L), avg_pop = c(9, 3, 9, 8, 26, 
    47.5, 29.5, 54, 45.5, 200.5, 221, 227, 222.5, 5.5, 4, 9, 
    4.5, 3.5, 2, 4, 4.5), SE_temp = c(0.499, 0.7, 0.6, 1.45, 
    2.381, 1.8, 1.4, 0.4, 1, 1.414, 0.707, 1.06, 0.353, 0.989, 
    0.565, 0.07, 2.121, 0.707, 0, 0, 7.07), CI_low_temp = c(25.025, 
    30.035, 32.03, 17.172, 20.119, 27.19, 15.47, 21.22, 18.05, 
    11.05, 13.025, 12.537, 12.512, 24.735, 26.52, 28.302, 12.075, 
    16.025, 20, 20, 10.25), CI_upper_temp = c(25.975, 31.365, 
    33.17, 19.927, 24.641, 30.61, 18.13, 21.98, 19.95, 12.95, 
    13.974, 13.962, 12.987, 26.065, 27.78, 28.397, 14.925, 16.975, 
    20, 20, 19.75), SE_pop = c(0, 1.414, 0, 1.414, 31.112, 10.606, 
    13.425, 24.041, 12.02, 26.162, 2.828, 5.656, 12.02, 0.707, 
    0, 1.414, 0.707, 0.707, 0, 2.828, 3.535), CI_pop_low = c(9, 
    2.05, 9, 7.05, 5.1, 40.375, 20.475, 37.85, 37.425, 182.925, 
    219.1, 223.2, 214.425, 5.025, 4, 8.05, 4.025, 2.025, 2, 3.1, 
    2.125), CI_pop_upper = c(9, 3.95, 9, 8.95, 46.9, 54.625, 
    38.525, 70.15, 53.575, 218.075, 222.9, 230.8, 230.575, 5.975, 
    4, 9.95, 4.975, 2.975, 2, 6.9, 6.875), Tempdiff = c(1, 1.4, 
    1.1, -2.9, 4.76, 3.6, 2.8, 0.800000000000001, 2, 2, 1, -1.5, 
    0.5, 1.4, 0.800000000000001, -0.0999999999999979, 3, -1, 
    0, 0, -10), popdiff = c(0L, -2L, 0L, -2L, -44L, -15L, -19L, 
    -34L, -17L, 37L, 4L, 8L, -17L, -1L, 0L, -2L, -1L, -1L, 0L, 
    4L, -5L), order = 1:21), .Names = c("Paper", "Specimen", 
"Site", "elevation", "yr1", "yr1pop", "yr1temp", "yr2", "yr2temp", 
"yr2pop", "delta_temp", "avg_temp", "delta_pop", "avg_pop", "SE_temp", 
"CI_low_temp", "CI_upper_temp", "SE_pop", "CI_pop_low", "CI_pop_upper", 
"Tempdiff", "popdiff", "order"), row.names = c(NA, 21L), class = "data.frame")

0 个答案:

没有答案