r - actual graph missing without error message -
i started trying visualize data using ggplot2 package in r , got point, looks fine. meaning, axis labeled correctly, having right tick-marks etc.
the problem although receive no error messages when running code below, actual graph inside plot not showing up. makes kind of hard me figure out, went wrong. suggestions on why (not) happening appreciated much.
time <- seq(as.date("2010-04-01"), as.date("2012-02-01"), = "2 months")
the vector of dates, used tick-marks. mark every 2nd month beginning earliest date in data until bit after last date.
qplot(date, sums/1000, data=sums[(sums$lake=="gollinsee") & (sums$maize=="no maize"),] ,color=location, group=location, main="gollinsee without maize") + geom_line(size=0.7) + geom_point(size=3) + labs(x="date", y=expression("total c [" * g %.% m^-3 * "]")) + scale_x_date(breaks=(time), limits=c(min(time), max(time)), labels=format.date(time, "%b %y"))
everything runs expected until add last line. without x-axis cluttered , dates in undesirable format. it, following image generated (unfortunately not allowed post images yet, links should work though):
http://i.stack.imgur.com/i6rry.png
the not presentable way plot looks without modified x-axis.
http://i.stack.imgur.com/widpz.png
kind regards!
edit: output of dput(sums)
structure(list(date = structure(c(1l, 1l, 2l, 2l, 3l, 3l, 4l, 5l, 6l, 6l, 7l, 7l, 8l, 8l, 9l, 9l, 11l, 11l, 19l, 10l, 10l, 12l, 12l, 14l, 14l, 16l, 16l, 19l, 15l, 20l, 20l, 13l, 13l, 17l, 17l, 18l, 20l, 20l, 22l, 22l, 18l, 4l, 21l, 25l, 28l, 25l, 25l, 23l, 23l, 23l, 23l, 28l, 24l, 24l, 24l, 24l, 22l, 22l, 22l, 22l, 21l, 25l, 35l, 35l, 37l, 37l, 35l, 35l, 37l, 37l, 39l, 39l, 39l, 39l, 36l, 28l, 33l, 33l, 33l, 33l, 31l, 31l, 31l, 31l, 29l, 29l, 29l, 26l, 26l, 26l, 26l, 27l, 27l, 27l, 27l, 30l, 30l, 30l, 30l, 32l, 32l, 32l, 32l, 34l, 34l, 34l, 34l, 38l, 38l, 38l, 38l, 36l, 36l), .label = c("2010-04-06", "2010-04-08", "2010-05-04", "2010-05-06", "2010-05-19", "2010-06-01", "2010-06-03", "2010-06-29", "2010-06-30", "2010-07-27", "2010-07-29", "2010-08-24", "2010-08-26", "2010-09-21", "2010-09-23", "2010-10-19", "2010-10-21", "2010-11-16", "2010-11-18", "2011-01-05", "2011-02-24", "2011-03-22", "2011-04-05", "2011-04-07", "2011-05-03", "2011-05-05", "2011-05-31", "2011-06-01", "2011-06-28", "2011-07-01", "2011-07-26", "2011-07-28", "2011-08-23", "2011-08-25", "2011-09-20", "2011-09-22", "2011-10-17", "2011-10-20", "2012-01-10" ), class = "factor"), lake = structure(c(1l, 1l, 2l, 2l, 1l, 1l, 2l, 1l, 1l, 1l, 2l, 2l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l), .label = c("gollinsee", "schulzensee"), class = "factor"), location = structure(c(2l, 1l, 2l, 1l, 2l, 1l, 2l, 2l, 2l, 1l, 2l, 1l, 2l, 1l, 2l, 1l, 2l, 1l, 1l, 2l, 1l, 2l, 1l, 2l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 1l, 2l, 2l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 1l, 1l, 2l, 2l, 2l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 1l, 1l, 2l, 1l, 2l, 1l, 2l, 2l, 2l, 1l, 1l, 2l, 2l, 2l, 1l, 1l, 2l, 2l, 1l, 2l, 2l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 1l, 1l, 2l, 1l, 2l, 1l, 2l, 2l, 1l, 1l, 2l, 1l, 2l, 1l, 1l, 2l ), .label = c("littoral", "pelagic"), class = "factor"), maize = structure(c(2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 1l, 2l, 2l, 1l, 1l, 1l, 1l, 2l, 1l, 2l, 1l, 2l, 2l, 1l, 2l, 1l, 2l, 2l, 1l, 1l, 2l, 2l, 2l, 2l, 1l, 1l, 2l, 2l, 1l, 1l, 2l, 2l, 2l, 1l, 1l, 2l, 1l, 1l, 1l, 2l, 2l, 1l, 2l, 1l, 2l, 2l, 1l, 1l, 2l, 1l, 1l, 2l, 2l, 1l, 2l, 1l, 1l, 2l, 2l, 1l, 1l, 1l, 2l, 2l, 1l, 2l, 2l, 1l, 2l, 1l, 1l, 2l, 2l, 1l ), .label = c("maize", "no maize"), class = "factor"), sums = c(388.7, 254.5, 320.4, 373.3, 224.1, 182.4, 245.5, 258.7, 47.7, 60.5, 58.3, 103.7, 311.9, 207.7, 283.9, 308.3, 237.9, 165.4, 556.4, 1090.4, 1792.6, 1350.5, 932.4, 526.5, 1157.8, 2343.7, 4570.9, 393.2, 315.5, 351, 1008, 504.8, 289.9, 113.4, 117.7, 707.9, 193.4, 122.2, 828.2, 1106.4, 837.8, 148, 777.6, 1824.6, 388, 1658.6, 636.3, 1434.7, 770.8, 1776.4, 705.9, 1634.5, 1237.1, 1882.5, 1073.8, 2283, 1030.7, 273, 194.6, 788.6, 1034.9, 420.7, 404.6, 295.9, 332, 229.3, 381, 304.2, 780.2, 227.3, 50.6, 509.3, 209.7, 675.8, 691.9, 651.7, 635.1, 560.8, 602.2, 1243.1, 733.8, 669.1, 574.5, 379.6, 1405.3, 513.6, 612.4, 1396.4, 256.7, 486.8, 521.3, 55.5, 48.2, 181.7, 281.3, 322.7, 478.1, 208.4, 173.8, 599.2, 262.9, 760.7, 365.5, 746.6, 790.3, 581.7, 388.9, 826.4, 132.6, 167.5, 817.6, 425.1, 582.2)), .names = c("date", "lake", "location", "maize", "sums"), class = "data.frame", row.names = c(na, -113l))
kind regards!
the problem "date" in sums factor. convert date type. might not have muck around defining "times" since think you're doing axis doesn't cluttered. having date actual date type should clean labels little bit.
sums$date <- as.date(sums$date) qplot(date, sums/1000, data=sums[(sums$lake=="gollinsee") & (sums$maize=="no maize"),], color=location, group=location, main="gollinsee without maize") + geom_line(size=0.7) + geom_point(size=3) + labs(x="date", y=expression("total c [" * g %.% m^-3 * "]"))
Comments
Post a Comment