I am very new to R, and am trying to create a scatter plot in ggplot2 which is in affect a scatter plot where each symbol is controlled in its width and height by two variables. I have come up with a work around using geom_errorbar and geo_errorbarh (code below) which is producing something along the lines I am looking for, but I want to be able to remove the error x/y mid cross lines and just leave a box for each datapoint, which I can colour in (I only need them to be in one colour). An example of the type of thing I am talking about is at: http://imbie.org/about-the-project/ice-sheet-mass-balance-measurements/
A subset of my data is (I hope I have used dput() correctly):
structure(list(Year = c(2000L, 1995L, 1986L, 1977L, 1977L, 1973L,
1973L, 1969L, 1965L, 1961L), RSL = c(0.02, 0.02, 0, -0.01, -0.07,
0, -0.11, -0.1, -0.16, -0.07), Age_error = c(2L, 1L, 5L, 4L,
3L, 4L, 3L, 2L, 2L, 3L), RSL_error = c(0.03, 0.04, 0.03, 0.03,
0.05, 0.03, 0.05, 0.05, 0.05, 0.03), plus_error = c(0.05, 0.06,
0.03, 0.02, -0.02, 0.03, -0.06, -0.05, -0.11, -0.04), minus_error = c(-0.01,
-0.02, -0.03, -0.04, -0.12, -0.03, -0.16, -0.15, -0.21, -0.1),
plus_age = c(2002L, 1996L, 1991L, 1981L, 1980L, 1977L, 1976L,
1971L, 1967L, 1964L), minus_age = c(1998L, 1994L, 1981L,
1973L, 1974L, 1969L, 1970L, 1967L, 1963L, 1958L), total_RSLerror = c(0.06,
0.08, 0.06, 0.06, 0.1, 0.06, 0.1, 0.1, 0.1, 0.06), total_Ageerror = c(4L,
2L, 10L, 8L, 6L, 8L, 6L, 4L, 4L, 6L)), .Names = c("Year",
"RSL", "Age_error", "RSL_error", "plus_error", "minus_error",
"plus_age", "minus_age", "total_RSLerror", "total_Ageerror"), class = "data.frame",
row.names = c ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"))
The code I have currently got is:
ggplot(data, aes(x=Year, y=RSL)) + geom_errorbar(aes(ymin=minus_error, ymax=plus_error, width=total_Ageerror)) + geom_errorbarh(aes(xmax=plus_age, xmin=minus_age, height=total_RSLerror)) + theme_bw()
Thank you ever so much in anticipation. Please let me know if I need to send anything else or if I have inputed this incorrectly.
