2d contour color map in ggplot2 - r

I have a huge data, please bear with me.
df <- structure(list(W = c(5216400.4123, 5399804.7349, 5595563.3087,
5792353.9932, 5993467.7466, 6189404.9279, 6380940.454, 6566630.3544,
6747453.6816, 6917820.9796, 7086201.8275, 7248213.5225, 5402700.4252,
5592654.9057, 5795404.8549, 5999223.7818, 6207520.1695, 6410455.1037,
6608831.1825, 6801152.8706, 6988434.1695, 7164886.0132, 7339280.46,
7507078.2886, 5589000.4397, 5785505.0748, 5995246.3993, 6206093.5662,
6421572.589, 6631505.2817, 6836721.9131, 7035675.3828, 7229414.6578,
7411951.0459, 7592359.0997, 7765943.0584, 5775300.4552, 5978355.2455,
6195087.9484, 6412963.3504, 6635625.0103, 6852555.4544, 7064612.6447,
7270197.897, 7470395.1463, 7659016.0859, 7845437.7356, 8024807.8293,
5961600.4694, 6171205.4145, 6394929.4952, 6619833.1358, 6849677.4283,
7073605.633, 7292503.372, 7504720.4062, 7711375.6354, 7906081.1161,
8098516.3724, 8283672.5987, 6147900.4816, 6364055.583, 6594771.0412,
6826702.9212, 7063729.8478, 7294655.8114, 7520394.1023, 7739242.9195,
7952356.1253, 8153146.1541, 8351595.0092, 8542537.3639, 6334200.5005,
6556905.7553, 6794612.5881, 7033572.7089, 7277782.2661, 7515705.9882,
7748284.8337, 7973765.4322, 8193336.6123, 8400211.1873, 8604673.6477,
8801402.1321, 6520500.5136, 6749755.9226, 6994454.1327, 7240442.494,
7491834.6868, 7736756.1617, 7976175.5621, 8208287.9459, 8434317.1037,
8647276.2228, 8857752.2827, 9060266.9029, 6706800.528, 6942606.0899,
7194295.6809, 7447312.2777, 7705887.1079, 7957806.3409, 8204066.2961,
8442810.4584, 8675297.5886, 8894341.2573, 9110830.9206, 9319131.6718,
6893100.5418, 7135456.2602, 7394137.2288, 7654182.0653, 7919939.5232,
8178856.5136, 8431957.0234, 8677332.969, 8916278.0804, 9141406.2918,
9363909.5543, 9577996.4404, 7079400.5588, 7328306.4296, 7593978.7729,
7861051.8503, 8133991.9462, 8399906.6912, 8659847.7579, 8911855.4821,
9157258.5684, 9388471.3277, 9616988.1903, 9836861.209, 7265700.5699,
7521156.5994, 7793820.3185, 8067921.639, 8348044.3652, 8620956.868,
8887738.4844, 9146377.9962, 9398239.0552, 9635536.362, 9870066.8286,
10095725.9764, 7377480.5806, 7636866.7018, 7913725.2471, 8192043.5082,
8476475.8166, 8753586.9712, 9024472.9255, 9287091.5011, 9542827.3494,
9783775.3823, 10021914.0099, 10251044.8357, 7452000.5846, 7714006.7682,
7993661.8669, 8274791.4235, 8562096.7846, 8842007.041, 9115629.2162,
9380900.5049, 9639219.5459, 9882601.398, 10123145.4642, 10354590.7474,
7526520.5952, 7791146.8356, 8073598.4841, 8357539.3348, 8647717.7534,
8930427.113, 9206785.5068, 9474709.5143, 9735611.7438, 9981427.4094,
10224376.9194, 10458136.6527, 7638300.6025, 7906856.9365, 8193503.4143,
8481661.2074, 8776149.2063, 9063057.2172, 9343519.9463, 9615423.0209,
9880200.0383, 10129666.4312, 10376224.1032, 10613455.5131, 7824600.6172,
8099707.1074, 8393344.9601, 8688530.993, 8990201.627, 9284107.395,
9571410.6772, 9849945.5329, 10121180.5245, 10376731.4677, 10629302.7393,
10872320.2844, 8010900.6306, 8292557.2766, 8593186.5077, 8895400.7788,
9204254.0428, 9505157.5709, 9799301.4089, 10084468.0455, 10362161.0109,
10623796.504, 10882381.3729, 11131185.0534, 8197200.6444, 8485407.4453,
8793028.0567, 9102270.5614, 9418306.465, 9726207.7477, 10027192.1371,
10318990.5604, 10603141.4991, 10870861.5368, 11135460.012, 11390049.8203,
8383500.6593, 8678257.6128, 8992869.6005, 9309140.3471, 9632358.8856,
9947257.9225, 10255082.8657, 10553513.0731, 10844121.988, 11117926.5692,
11388538.6484, 11648914.5899, 8569800.6735, 8871107.7799, 9192711.1487,
9516010.1349, 9846411.3046, 10168308.0987, 10482973.5998, 10788035.5824,
11085102.4738, 11364991.6051, 11641617.2821, 11907779.3576, 8756100.6891,
9063957.9534, 9392552.6936, 9722879.9204, 10060463.7195, 10389358.2746,
10710864.3279, 11022558.0956, 11326082.9668, 11612056.6477, 11894695.9209,
12166644.1258, 8942400.705, 9256808.1204, 9592394.2396, 9929749.7037,
10274516.1413, 10610408.4494, 10938755.0613, 11257080.6099, 11567063.455,
11859121.6771, 12147774.5594, 12425508.8956, 9128700.7203, 9449658.2901,
9792235.786, 10136619.4908, 10488568.5635, 10831458.6249, 11166645.792,
11491603.1215, 11808043.9427, 12106186.7106, 12400853.1962, 12684373.664,
9315000.7353, 9642508.4595, 9992077.3349, 10343489.2758, 10702620.9802,
11052508.7998, 11394536.5185, 11726125.6341, 12049024.431, 12353251.7462,
12653931.8307, 12943238.4324, 9501300.7465, 9835358.6307, 10191918.8807,
10550359.0623, 10916673.4022, 11273558.9758, 11622427.2509, 11960648.1479,
12290004.92, 12600316.7835, 12907010.4688, 13202103.2002, 9687600.7612,
10028208.7979, 10391760.4269, 10757228.8467, 11130725.8198, 11494609.1532,
11850317.9787, 12195170.6632, 12530985.4111, 12847381.8161, 13160089.1051,
13460967.9711), t = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L), .Label = c("t_m75_tc", "t_m5_tc", "t_m25_tc", "t_p0_tc",
"t_p25_tc", "t_p5_tc", "t_p75_tc", "t_p10_tc", "t_p125_tc", "t_p15_tc",
"t_p175_tc", "t_p20_tc"), class = "factor"), p = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L), .Label = c("h_30", "h_27.5", "h_25", "h_22.5",
"h_20", "h_17.5", "h_15", "h_12.5", "h_10", "h_7.5", "h_5", "h_2.5",
"h_1", "h0", "h1", "h2.5", "h5", "h7.5", "h10", "h12.5", "h15",
"h17.5", "h20", "h22.5", "h25", "h27.5", "h30"), class = "factor"),
tt = c(-7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5,
20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20,
-7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5,
-5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5,
-2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5,
0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0,
2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5,
5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5,
7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5,
10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10,
12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5,
15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15,
17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5,
20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20,
-7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5,
-5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5,
-2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5,
0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0,
2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5,
5, 7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5,
7.5, 10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5,
10, 12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10,
12.5, 15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5,
15, 17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15,
17.5, 20, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5,
20), hh = c(-30, -30, -30, -30, -30, -30, -30, -30, -30,
-30, -30, -30, -27.5, -27.5, -27.5, -27.5, -27.5, -27.5,
-27.5, -27.5, -27.5, -27.5, -27.5, -27.5, -25, -25, -25,
-25, -25, -25, -25, -25, -25, -25, -25, -25, -22.5, -22.5,
-22.5, -22.5, -22.5, -22.5, -22.5, -22.5, -22.5, -22.5, -22.5,
-22.5, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20,
-20, -20, -17.5, -17.5, -17.5, -17.5, -17.5, -17.5, -17.5,
-17.5, -17.5, -17.5, -17.5, -17.5, -15, -15, -15, -15, -15,
-15, -15, -15, -15, -15, -15, -15, -12.5, -12.5, -12.5, -12.5,
-12.5, -12.5, -12.5, -12.5, -12.5, -12.5, -12.5, -12.5, -10,
-10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -7.5,
-7.5, -7.5, -7.5, -7.5, -7.5, -7.5, -7.5, -7.5, -7.5, -7.5,
-7.5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -2.5,
-2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5,
-2.5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
2.5, 2.5, 2.5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7.5, 7.5,
7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12.5, 12.5, 12.5,
12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 17.5, 17.5, 17.5,
17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22.5, 22.5, 22.5,
22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 27.5, 27.5, 27.5,
27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 27.5, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30), pChange = c(-36.9603395985828,
-34.7439172960321, -32.3781951432773, -30.0000000392759,
-27.5695610939649, -25.2016804880133, -22.8869934306931,
-20.6429501564101, -18.4577189167867, -16.3988477104845,
-14.3639825485445, -12.4060879418008, -34.7089231777299,
-32.4133428932464, -29.9631306906258, -27.5000000028702,
-24.982759663634, -22.5303119363876, -20.1329575059591, -17.8087697620382,
-15.5454946011909, -13.4130922883195, -11.3055534045631,
-9.27773397066822, -32.4575067375413, -30.082768511005, -27.5480662597272,
-25.000000017221, -22.3959582743917, -19.8589433581751, -17.3789215558468,
-14.974589416006, -12.6332702807612, -10.4273368770308, -8.24712417357041,
-6.14937995482153, -30.2060902852677, -27.7521941094277,
-25.1330017720295, -22.5000000339888, -19.8091568633966,
-17.1875748440126, -14.6248855936495, -12.1404090458039,
-9.72104595791446, -7.44158137752243, -5.18869498850033,
-3.02102592568144, -27.9546738487045, -25.4216197283948,
-22.7179373121271, -20.0000000362547, -17.2223554922816,
-14.5162062585492, -11.8708496834174, -9.30622873602633,
-6.80882162781682, -4.45582599644603, -2.13026579255384,
0.107328085331291, -25.7032574363111, -23.0910453534044,
-20.3028728618926, -17.5000000385206, -14.6355541030393,
-11.8448376755028, -9.11681373693055, -6.47204837670069,
-3.89659728805126, -1.47007052110743, 0.928163403392649,
3.23568204558746, -23.4518409429489, -20.7604709324913, -17.8878084007817,
-15.0000000129913, -12.0487527282989, -9.17346911179217,
-6.36277777715033, -3.63786802462598, -0.984372983331903,
1.51568489622367, 3.98659261988347, 6.36403604209831, -21.2004245196791,
-18.4298965720027, -15.4727439674661, -12.5000000188826,
-9.46195132455473, -6.50210058796172, -3.6087418536248, -0.803687660466381,
1.92785137456101, 4.50144034135001, 7.04502179407714, 9.4923900700299,
-18.949008080699, -16.0993222115141, -13.0576794906449, -10.0000000416929,
-6.8751499159766, -3.83073199524737, -0.85470586242384, 2.03049268919135,
4.84007565390208, 7.48719577439149, 10.103451003317, 12.6207440750002,
-16.6975916489697, -13.7687478147708, -10.6426150174491,
-7.50000001737204, -4.28834857749088, -1.15936348108484,
1.8993300478083, 4.86467301588778, 7.75230001662893, 10.4729512074329,
13.1618801618003, 15.749098076345, -14.4461751785688, -11.4381734289039,
-8.2275505901759, -5.00000002447191, -1.70154714595145, 1.51200509229367,
4.65336604505171, 7.69885337279645, 10.6645243334332, 13.4587066573933,
16.2203093480789, 18.8774520776898, -12.1947587794688, -9.10759903820312,
-5.81248614477539, -2.49999998685766, 0.885254237248392,
4.18337365600429, 7.40740194561595, 10.53303374179, 13.5767486357356,
16.4444620880177, 19.2787385621527, 22.0058060645328, -10.8439088911858,
-7.70925439749847, -4.3634474625498, -1.00000001287041, 2.43733506716831,
5.78619475942614, 9.05982354879595, 12.2335419201639, 15.324083242737,
18.2359153430087, 21.1137960702944, 23.8828184428618, -9.94334233686319,
-6.77702465958718, -3.39742166553716, 0, 3.47205562528221,
6.85474217379226, 10.1614379102301, 13.3672140455251, 16.4889729851691,
19.4302175391865, 22.3371677435973, 25.1341600948813, -9.04277570278022,
-5.84479490959099, -2.43139589994524, 0.999999964530837,
4.50677619306401, 7.92328961474518, 11.2630522704558, 14.5008862385618,
17.65386274452, 20.6245196833994, 23.5605394277767, 26.3855016695576,
-7.69192585558588, -4.44645028701369, -0.982357198383821,
2.49999997960674, 6.05885704111126, 9.52611073025193, 12.9154738543,
16.20139443748, 19.4011973551469, 22.4159729565176, 25.3955969661306,
28.26251406118, -5.44050941298024, -2.11587588301946, 1.43270724943368,
4.99999997975781, 8.64565844485543, 12.1974793060474, 15.6695098080378,
19.0355747810953, 22.3134216501983, 25.4017284137289, 28.4540261536177,
31.390868095154, -3.18909298608498, 0.214698500430437, 3.84777171900399,
7.49999998232584, 11.2324597893836, 14.8688478588816, 18.4235457714435,
21.8697551319615, 25.2256459476667, 28.3874838685232, 31.5124553108925,
34.5192221013328, -0.93767655435575, 2.54527287783788, 6.26283620549316,
9.99999994622222, 13.8192612112551, 17.5402164225922, 21.177581692552,
24.703935510623, 28.1378702668879, 31.3732392810203, 34.5708845346342,
37.6475760821333, 1.31373989066688, 4.87584724074345, 8.67790062914087,
12.4999999475818, 16.4060626137908, 20.211584962133, 23.9316176184945,
27.5381158626977, 31.0500945945686, 34.3589946886835, 37.6293137257467,
40.775930095563, 3.56515632723005, 7.20642159881506, 11.0929651059621,
14.9999999743196, 18.9928639969906, 22.8829535185927, 26.685653610904,
30.3722961736837, 33.9623188847861, 37.3447501386438, 40.6877428842301,
43.9042840860314, 5.81657278071209, 9.53699603423, 13.5080295429032,
17.4999999732622, 21.5796653306424, 25.5543220714269, 29.439689530804,
33.2064765318009, 36.8745432620148, 40.3305056695729, 43.7461721043463,
47.0326380825422, 8.06798923781962, 11.8675703910931, 15.9230939931377,
19.999999945618, 24.16646674768, 28.2256906109677, 32.1937255147541,
36.0406569032114, 39.7867675812361, 43.3162610409814, 46.8046013208372,
50.1609920983889, 10.3194056876762, 14.1981447805855, 18.3381584482061,
22.4999999638964, 26.7532681695515, 30.8970591589679, 34.9477614660749,
38.8748372419928, 42.6989918944149, 46.302016461938, 49.8630305167836,
53.2893460973168, 12.5708221339073, 16.5287191664524, 20.7532229334868,
24.9999999567965, 29.3400695249561, 33.5684276997172, 37.7017973666391,
41.709017592859, 45.6112162148446, 49.2877719082728, 52.9214596849349,
56.4177000962446, 14.8222385342158, 18.859293574072, 23.1682873813043,
27.499999967824, 31.9268709444106, 36.2397962537599, 40.4558333385042,
44.5431979582271, 48.5234405437337, 52.273527375152, 55.9798888965917,
59.5460540879215, 17.0736549768214, 21.1898679333522, 25.5833518339557,
29.9999999534732, 34.5136723106916, 38.9111648247215, 43.2098692547788,
47.3773783417225, 51.4356648980012, 55.2592827852321, 59.0383180864958,
62.6744081170616)), class = "data.frame", .Names = c("W",
"t", "p", "tt", "hh", "pChange"), row.names = c(NA, -324L))
I am trying to plot a colored contour map with the columns tt, hh and W, W being the z axis.
This is the code I am using::
ggplot(df, aes(x = tt, y = hh, z = W)) +
stat_contour(geom = "polygon", aes(fill = ..level..) ) +
geom_tile(aes(fill = W)) +
stat_contour(bins = 10) +
xlab("% change in temperature") +
ylab("% change in ppt") +
guides(fill = guide_colorbar(title = "W"))
This is the result I got:
What I want is the color to be continuous, as seen here I am following this example for my work.
What is going wrong over here?

The grid is not evenly spaced. One way to make an evenly spaced grid is to use interpolate using loess on an evenly spaced grid:
model <- loess(W ~ tt + hh, data = df)
create an evenly spaced grid using expand.grid:
new.data <- expand.grid(tt = seq(from = min(df$tt), to = max(df$tt), length.out = 500),
hh = seq(from = min(df$hh), to = max(df$hh), length.out = 500))
predict on new data using the model:
gg <- predict(model, newdata = new.data)
combine prediction and new data:
new.data = data.frame(W = as.vector(gg),
new.data)
and now the plot looks like:
ggplot(new.data, aes(x = tt, y = hh, z = W)) +
stat_contour(geom = "polygon", aes(fill = ..level..) ) +
geom_tile(aes(fill = W)) +
stat_contour(bins = 10) +
xlab("% change in temperature") +
ylab("% change in ppt") +
guides(fill = guide_colorbar(title = "W"))
You might also want to check some goodness of fit metric for loess
caret::RMSE(model$fitted, df$W)
#output
7498.393
using a narrower span could provide a better fit, especially if the data is not smooth:
model2 <- loess(W ~ tt + hh, data = df, span = 0.1)
caret::RMSE(model2$fitted, df$W)
#output
964.7582
ggplot(new.data2, aes(x = tt, y = hh, z = W)) +
stat_contour(geom = "polygon", aes(fill = ..level..) ) +
geom_tile(aes(fill = W)) +
stat_contour(bins = 10) +
xlab("% change in temperature") +
ylab("% change in ppt") +
guides(fill = guide_colorbar(title = "W"))
The difference is ever so slight
ggplot(new.data, aes(x = tt, y = hh, z = W)) +
geom_tile(aes(fill = W)) +
geom_contour(aes(x = tt, y = hh, z = W),
color = "red")+
geom_contour(data = new.data2,
aes(x = tt, y = hh, z = W),
color = "white", inherit.aes = FALSE)
EDIT: also check the great post by #Henrik which is linked by him in the comment. Especially the ?akima::interp function.
EDIT2: answer to the questions in comments:
To specify a different fill one can use
scale_fill_gradient
scale_fill_gradient2
scale_fill_gradientn
Here is an example of using scale_fill_gradientn with 5 colors based on quantiles:
v <- ggplot(new.data2, aes(x = tt, y = hh, z = floor(W))) +
geom_tile(aes(fill = W), show.legend = FALSE) +
stat_contour(bins = 10, aes(colour = ..level..)) +
xlab("% change in temperature") +
ylab("% change in ppt") +
guides(fill = guide_colorbar(title = "W")) +
scale_fill_gradientn(values = scales::rescale(quantile(new.data2$W)),
colors = rainbow(5))
I removed the polygon thing since it was below the geom_tile layer and was not visible.
To add direct labels:
library(directlabels)
direct.label(v, list("far.from.others.borders", "calc.boxes", "enlarge.box",
box.color = NA, fill = "transparent", "draw.rects"))

Related

geom_tile tiles displaced when using ggplotly

Issue:
When using ggplotly in combination with geom_tile, in the following reprex (see below), tiles are displaced.
ggplot output:
ggplotly output:
As you can see, the y-values are partially off-placed by one and the x-values are partially off-placed by a lot.
plotly raises the following warning:
Versions: I have the same issue using R version 3.5.3 and 4.0.1., using ggplot2 version 3.1.1/3.3.3 and plotly version 3.9.0/4.9.3 respectively.
Question: How can I fix this issue such that the ggplotly graph has the same, correct tile placement as the original ggplot2 graph?
Reprex:
library(ggplot2)
library(plotly)
library(data.table)
dt <- structure(list(x = c(5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 7, 8, 9, 11, 12, 13, 14, 15,
16, 17, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), y = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L,
26L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L, 27L, 27L,
27L, 27L, 27L, 27L, 27L, 27L, 27L), Color = c(0.105263157894737,
0.0736842105263158, -0.136842105263158, -0.136842105263158, -0.221052631578947,
0.105263157894737, 0.0421052631578947, -0.031578947368421, -0.136842105263158,
-0.178947368421053, -0.210526315789474, -0.242105263157895, -0.263157894736842,
NA, NA, 0.761904761904762, 0.619047619047619, 0.523809523809524,
0.476190476190476, 0.380952380952381, 1.19047619047619, 1.0952380952381,
1.04761904761905, 0.952380952380952, 0.904761904761905, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.436923076923077,
0.313846153846154, 0.704615384615385, 1.56615384615385, 1.44307692307692,
1.19692307692308, 1.13230769230769, 1.04, 0.947692307692308,
0.916923076923077, 0.898461538461538, 0.876923076923077, 1.76923076923077,
0.569105691056911, 0.447154471544715, 0.894308943089431, 0.853658536585366,
0.731707317073171, 0.634146341463415, 0.58130081300813, 0.33739837398374,
0.313008130081301, 0.272357723577236, 0.252032520325203, 0.235772357723577,
1.4390243902439, NA, 1.09195402298851, 1.07471264367816, 1.47701149425287,
1.4367816091954, 1.83908045977012, 2.35632183908046, 2.18390804597701,
1.95402298850575, 1.94252873563218, 1.92528735632184, 1.91379310344828,
1.89080459770115, 3.59770114942529, NA, 0.457227138643068, 0.752212389380531,
0.604719764011799, 0.471976401179941, 0.678466076696165, 0.575221238938053,
0.457227138643068, 0.56047197640118, 0.530973451327434, 0.497050147492625,
0.463126843657817, 0.548672566371681, NA, 0.273665320771646,
0.165993719156572, 0.122625990728279, 0.272169881860326, 0.182443547181098,
0.0373859727830118, -0.091969493046209, -0.153282488410348, -0.108419321070734,
-0.129355465829221, -0.145057574398086, -0.157918349035442, -0.0354419021982952,
NA, 0.336239103362391, 0.62266500622665, 0.460772104607721, 0.361145703611457,
0.24906600249066, 0.161892901618929, 0.386052303860523, 0.311332503113325,
0.261519302615193, 0.23412204234122, 0.207970112079701, 0.183063511830635,
NA, 0.39348710990502, 0.251017639077341, 0.33921302578019, 0.617367706919946,
0.597014925373134, 0.556309362279512, 0.461329715061058, 0.345997286295794,
0.440976933514247, 0.400271370420624, 0.37449118046133, 0.347354138398915,
0.831750339213026, 0.820189274447949, 0.725552050473186, 0.630914826498423,
0.599369085173502, 0.378548895899054, 0.157728706624606, 0.126182965299685,
0.0630914826498423, 0.517350157728707, 0.495268138801262, 0.476340694006309,
0.451104100946372, 0.892744479495268, 0.632743362831858, 0.411504424778761,
0.942477876106195, 0.853982300884956, 0.809734513274336, 0.721238938053097,
0.676991150442478, 0.455752212389381, 0.438053097345133, 0.411504424778761,
0.389380530973451, 0.36283185840708, 0.327433628318584, 0.746268656716418,
0.54726368159204, 0.462686567164179, 0.412935323383085, 0.114427860696517,
0.796019900497512, 0.746268656716418, 0.681592039800995, 0.6318407960199,
0.592039800995025, 0.552238805970149, 0.527363184079602, 0.492537313432836,
NA, 0.402097902097902, 0.340909090909091, 0.236013986013986,
0.131118881118881, 0.236013986013986, 0.0262237762237762, -0.0174825174825175,
-0.0699300699300699, 0.13986013986014, 0.106643356643357, 0.0769230769230769,
0.0629370629370629, 0.048951048951049, NA, 0.476495726495726,
0.391025641025641, 0.252136752136752, 0.273504273504273, 0.412393162393162,
0.391025641025641, 0.358974358974359, 0.273504273504273, 0.145299145299145,
0.123931623931624, 0.0737179487179487, 0.0416666666666667, 0.111111111111111,
NA, 0.777385159010601, 0.600706713780919, 0.353356890459364,
0.49469964664311, 0.459363957597173, 0.653710247349823, 0.618374558303887,
0.547703180212014, 0.512367491166078, 0.484098939929329, 0.45583038869258,
0.431095406360424, 0.696113074204947, NA, 1.06481481481481, 0.925925925925926,
0.694444444444445, 1.01851851851852, 0.694444444444445, 0.648148148148148,
0.601851851851852, 0.569444444444445, 0.541666666666667, 0.523148148148148,
0.50462962962963, 0.490740740740741, 0.851851851851852, NA, 0.574712643678161,
0.498084291187739, 0.383141762452107, 0.651340996168582, 0.53639846743295,
0.762452107279693, 0.67816091954023, 0.448275862068965, 0.409961685823755,
0.333333333333333, 0.283524904214559, 0.245210727969349, 0.532567049808429,
1.04166666666667, 0.925925925925926, 0.740740740740741, 0.717592592592593,
0.625, 0.671296296296296, 0.625, 0.578703703703704, 0.532407407407407,
0.643518518518518, 0.578703703703704, 0.518518518518518, 0.851851851851852,
NA, 0.775193798449612, 0.682170542635659, 0.578811369509044,
0.527131782945736, 1.25064599483204, 1.19896640826873, 0.96640826873385,
0.837209302325581, 0.75968992248062, 0.689922480620155, 0.674418604651163,
0.664082687338501, 0.86046511627907, 0.783132530120482, 0.642570281124498,
0.582329317269076, 0.522088353413655, 0.642570281124498, 0.522088353413655,
0.421686746987952, 0.281124497991968, 0.200803212851406, 0.180722891566265,
0.112449799196787, 0.0562248995983936, 0.305220883534137, 1.89473684210526,
1.78947368421053, 1.73684210526316, 1.47368421052632, 1.47368421052632,
1.36842105263158, 1.26315789473684, 1.21052631578947, 1.10526315789474,
1.10526315789474, NA, NA, NA, NA, NA, NA, NA, NA, 2.25, 2, 2,
2, 1.53153153153153, 1.35135135135135, 1.21621621621622, 1.08108108108108,
0.990990990990991, 0.986486486486486, 0.981981981981982, 0.711711711711712,
0.621621621621622, 0.576576576576577, 0.576576576576577, 0.576576576576577,
1.02702702702703, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 0.129740518962076, 0.0449101796407186, -0.0998003992015968,
-0.229540918163673, -0.384231536926148, -0.484031936127745, -0.62874251497006,
-0.738522954091816, -0.828343313373254, -0.838323353293413, -0.839321357285429,
-0.839820359281437, -0.800399201596807, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA, -355L), class = c("data.table",
"data.frame"))
p <- ggplot(dt, aes(x, y, fill = Color)) + geom_tile()
p
g <- ggplotly(p)
g
The problem is that you have the same coordinates repeated more than once with different values for the Color variable. Indeed if you check how many unique combinations for x and y you have there are only 346 not 355 as the number of rows in your data.table.
nrow(unique(dt[, .(x, y)]))
# [1] 346
If you try changing this line of your example:
p <- ggplot(dt, aes(x, y, fill = Color)) + geom_tile()
to
p <- ggplot(unique(dt, by = c('x', 'y')), aes(x, y, fill = Color)) + geom_tile()
you will get the same plot in both ggplot2 and plotly.
Best!

complex ggplot in R - half circular bar plot

Okay so here is the challenge. How do recreate this chart?
The numbers and so on does not have to match, what I am really trying to do is create a circular bar chart in a gauge type layout with the gap. Headers and text is optional. More just the idea of a 3/4 circular bar chart.
Here is some example code that I am playing with:
library(ggplot2)
fixed_income.df <- data.frame(name = c("total","US Gov't Debt","US Municipal Debt",
"US IG Corp","US HY Corp","Int'l Developed",
"Emerging Market"),
allocation = c(3,1,4,3,4,2,3),
x_ax = c(1:7))
ggplot(fixed_income.df,aes(x = as.numeric(x_ax), y = allocation)) +
geom_bar(stat = "identity") +
ylim(-5,5) +
coord_polar(
theta = "x",
start=-3)
) + coord_flip()
which returns:
ANy help will earn a cookie! No really any help would be so appreciated, I am stuck..
Sody
The code for the basic plot is fairly simple (at least, without the annotations)
library(ggplot2)
ggplot(df, aes(xvals, yvals, fill = cols)) +
geom_col(width = 1) +
scale_y_continuous(limits = c(-2, 3)) +
scale_fill_manual(values = rev(c("#e9cbc1", "#b54649", "gray90",
"gray50", "#8ba55d", "#e2e4d6",
"white", "#c3a891", "#37959d",
"#5c7890", "#dcad3c", "#55a3b9",
"#f39068"))) +
theme_void() +
geom_vline(colour = "white", xintercept = c(0.5, 1.5, 8.5, 15.5, 16.5, 17.5),
size = 3) +
geom_segment(data = data.frame(x = 0.5 + 1:23, y = 0, yend = 1),
aes(x = x, y = 0, yend = 1, xend = x), colour = "white",
inherit.aes = FALSE) +
scale_x_continuous(expand = c(0.2, 1)) +
coord_polar(start = -pi) +
theme(legend.position = "none")
It's getting your data in the correct format that's going to be difficult:
df <- structure(list(xvals = c(1L, 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, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L), yvals = c(0.45,
0, 0, 0.1, 0, 0.45, 0.5, 1, 0, 0, 0, 0, 0, 0.45, 0, 0.05, 0,
0.2, 0.3, 0.5, 0, 1, 0, 0, 0, 0, 0.3, 0.15, 0.05, 0, 0, 0.5,
0.5, 0, 1, 0, 0, 0, 0, 0.3, 0.15, 0.05, 0, 0, 0.5, 0.5, 0, 1,
0, 0, 0, 0, 0.45, 0, 0.05, 0, 0.2, 0.3, 0.5, 0, 1, 0, 0, 0, 0,
0.45, 0, 0.05, 0, 0.2, 0.3, 0.5, 0, 1, 0, 0, 0, 0, 0.45, 0, 0,
0.1, 0, 0.45, 0.5, 0, 1, 0, 0, 0, 0, 0.45, 0, 0, 0.1, 0, 0.45,
0.5, 0, 1, 0, 0, 0, 0, 0.3, 0.15, 0.05, 0, 0, 0.5, 0.5, 0, 0,
1, 0, 0, 0, 0.15, 0.3, 0.05, 0, 0, 0.5, 0.5, 0, 0, 1, 0, 0, 0,
0.45, 0, 0.05, 0, 0.2, 0.3, 0.5, 0, 0, 1, 0, 0, 0, 0.45, 0, 0,
0.1, 0, 0.45, 0.5, 0, 0, 1, 0, 0, 0, 0.45, 0, 0.05, 0, 0.2, 0.3,
0.5, 0, 0, 1, 0, 0, 0, 0.3, 0.15, 0.05, 0, 0, 0.5, 0.5, 0, 0,
1, 0, 0, 0, 0.45, 0, 0, 0.1, 0, 0.45, 0.5, 0, 0, 1, 0, 0, 0,
0.45, 0, 0, 0.1, 0, 0.45, 0.5, 0, 0, 0, 1, 0, 0, 0.45, 0, 0,
0.1, 0, 0.45, 0.5, 0, 0, 0, 0, 1, 0, 0.45, 0, 0.05, 0, 0.2, 0.3,
0.5, 0, 0, 0, 0, 0, 1, 0.3, 0.15, 0.05, 0, 0, 0.5, 0.5, 0, 0,
0, 0, 0, 1, 0.45, 0, 0, 0.1, 0, 0.45, 0.5, 0, 0, 0, 0, 0, 1,
0.45, 0, 0, 0.1, 0, 0.45, 0.5, 0, 0, 0, 0, 0, 1, 0.45, 0, 0,
0.1, 0, 0.45, 0.5, 0, 0, 0, 0, 0, 1, 0.45, 0, 0, 0.1, 0, 0.45,
0.5, 0, 0, 0, 0, 0, 1), cols = structure(c(13L, 12L, 11L, 10L,
9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L,
7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L,
5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L,
3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L,
1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L,
12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L,
11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L,
10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L,
9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L,
7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L,
5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L,
3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L,
1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L,
12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L,
11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L,
10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L,
9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L,
7L, 6L, 5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L,
5L, 4L, 3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L,
3L, 2L, 1L, 13L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L,
1L), .Label = c("Nesting Variable 6", "Nesting Variable 5",
"Nesting Variable 4",
"Nesting Variable 3", "Nesting Variable 2", "Nesting Variable 1",
"blank", "mint", "green", "darkgray", "lightgray", "red", "pink"
), class = "factor")), class = "data.frame", row.names = c(NA,
-299L))
OMG blonde moment, the answer is so simple.. How did I miss it..
xlim()

Cannot use self-starting models when manually defining maxiter for nls()?

Data:
structure(list(ID = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L,
37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 59L, 60L, 61L,
62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L), Stage = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 3L, 3L, 5L, 5L, 5L, 1L, 1L, 6L, 6L,
4L, 4L, 2L, 2L, 7L, 7L), .Label = c("milpa", "robir", "jurup che",
"pak che kor", "mehen che", "nu kux che", "tam che"), class = "factor"),
Time.Since.Burn = c(4, 2, 0.21, 2, 0.42, 4, 0.33, 0.33, 3,
6, 2.5, 5, 4, 5, 1.5, 6, 4, 6, 3, 6.5, 6.5, 6, 4, 2.5, 12,
10, 8, 18, 5, 10, 8, 16, 28, 22, 22, 21, 20, 18, 30, 27,
30, 36, 36, 40, 32, 28, 50, 32, 60, 60, 60, 60, 60, 60, 60,
60, 6, 6, 24, 26, 22, 2, 1, 50, 45, 10, 10, 4, 4, 60, 60),
meandec = c(0.3625, 0.3025, 0.275, 0.1075, 0.26, 0.395, 0.265,
0.4075, 0.9, 0.9275, 0.7075, 0.9625, 0.7725, 0.9325, 0.9875,
0.81, 0.575, 0.3075, 0.4675, 0.6975, 0.33, 0.8725, 0.46,
0.19, 0.495, 0.3825, 0.58, 0.2275, 0.45, 0.3925, 0.605, 0.515,
0.425, 0.34, 0.2475, 0.1375, 0.4225, 0.505, 0.36, 0.4325,
0.26, 0.1575, 0.125, 0.3125, 0.1725, 0.3175, 0.43, 0.3475,
0.2025, 0.395, 0.12, 0.1625, 0.3175, 0.1975, 0.1525, 0.2775,
0.4975, 0.725, 0.04, 0.326666666666667, 0.1425, 0.445, 0.4725,
0.3775, 0.27, 0.2225, 0.23, 0.3275, 0.9725, 0.215, 0.2325
)), row.names = c(NA, -71L), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"), vars = c("ID", "Stage"), drop = TRUE)
Problem:
I'm trying to run an exponential decay model on these data. I've done it with similar data, but when I try to do it on this particular dataset, it says that the number of max iterations has been exceeded without convergence.
nonlinmod6<-nls(meandec~SSasymp(Time.Since.Burn, Asym,R0,lrc),data=averaged_perherb)
Error in nls(y ~ cbind(1 - exp(-exp(lrc) * x), exp(-exp(lrc) * x)), data = xy, : number of iterations exceeded maximum of 50
So, I tried to manually increase the maximum number of iterations using the code below:
nonlinmod6<-nls(meandec~SSasymp(Time.Since.Burn, Asym,R0,lrc),data=averaged_perherb,nls.control(maxiter=500))
but it then gives me an error saying that :
Error in nls(meandec ~ SSasymp(Time.Since.Burn, Asym, R0, lrc), data =
averaged_perherb,: parameters without starting value in 'data': Asym, R0, lrc
which I don't think should be the case given that I'm using a self-starting function to identify the starting parameters. Is there any way to resolve this?
The problem is that the SSaymp intialization routine itself uses nls and it is that hidden invocation of nls that is the problem.
You are going to have to hack the intialization routine. Make a new copy of SSasymp called SSasymp2, grab its initialization routine and call it SSasymp2Init, say. Then use trace to insert into the initialization a new version of nls having the required control argument. To do that we use the partial function in the pryr package. Replace the initialization routine with the hacked one and then run nls.
library(pryr)
SSasymp2 <- SSasymp
SSasymp2Init <- attr(SSasymp2, "initial")
trace(SSasymp2Init,
quote(nls <- partial(stats::nls, control = nls.control(maxiter = 500))))
attr(SSasymp2, "initial") <- SSasymp2Init
nls(meandec ~ SSasymp2(Time.Since.Burn, Asym, R0, lrc), data = averaged_perherb)
giving:
Tracing (attr(object, "initial"))(mCall = mCall, data = data, LHS = LHS) on entry
Nonlinear regression model
model: meandec ~ SSasymp2(Time.Since.Burn, Asym, R0, lrc)
data: averaged_perherb
Asym R0 lrc
0.1641 0.5695 -3.4237
residual sum-of-squares: 2.977
Number of iterations to convergence: 15
Achieved convergence tolerance: 5.875e-06

ggmap with ggsubplot creates blank map

I am trying to place some plots on a map but nothing appears on the map. Here is a reproducible example. The first plot shows how each subplot should look. The second excludes the map but the subplot sizes are too large. The last is one attempt at the final product. I have tried many permutations but this has me stuck. Thanks in advance.
library(ggplot2)
library(ggmap)
library(ggsubplot)
pDat <- structure(list(Location = structure(c(13L, 12L, 14L, 14L, 15L, 15L, 16L, 16L, 17L, 17L, 18L, 19L, 32L, 19L, 19L, 20L, 20L, 20L, 21L, 21L, 21L, 22L, 22L, 22L, 23L, 23L, 24L, 25L, 25L, 26L, 27L, 28L, 28L, 29L, 30L, 30L, 31L), .Label = c("PW-29", "PW-31", "PW-32", "PW-33", "PW-35", "PW-36", "PW-37", "PW-38", "PW-39", "PW-40", "PW29", "SD-03", "SD-03a", "SD-12", "SD-18", "SD-19", "SD-27", "SD-29", "SD-30", "SD-31", "SD-32", "SD-33", "SD-35", "SD-36", "SD-37", "SD-38", "SD-40", "SD-41", "SD-42", "SD-43", "SD-44", "SD30"), class = "factor"), Lat = c(47.292351, 47.292351, 47.289376, 47.289376, 47.288299, 47.288299, 47.288014, 47.288014, 47.287338, 47.287338, 47.29476, 47.293246, 47.293246, 47.293246, 47.293246, 47.293259, 47.293259, 47.293259, 47.292206, 47.292206, 47.292206, 47.291523, 47.291523, 47.291523, 47.290496, 47.290496, 47.289826, 47.288262, 47.288262, 47.287735, 47.286672, 47.290059, 47.290059, 47.290482, 47.28852, 47.28852, 47.288377), Long = c(-73.098418, -73.098418, -73.101282, -73.101282, -73.102558, -73.102558, -73.102178, -73.102178, -73.103016, -73.103016, -73.096432, -73.096412, -73.096412, -73.096412, -73.096412, -73.098245, -73.098245, -73.098245, -73.097552, -73.097552, -73.097552, -73.100022, -73.100022, -73.100022, -73.099395, -73.099395, -73.100051, -73.101199, -73.101199, -73.101895, -73.102629, -73.100954, -73.100954, -73.100184, -73.102246, -73.102246, -73.101477), SBD_ft = c(0, 2, 0, 7, 0, 10, 0, 6, 2, 5, 0, 0.5, 0.5, 0, 2.5, 0.5, 0, 3, 0.5, 0, 2.5, 0.5, 0, 2.5, 0.5, 0, 0, 0.5, 0, 0, 0, 2, 5, 3, 0, 6, 0), SED_ft = c(20, 4, 2, 9, 2, 12, 2, 8, 4, 7, 0.5, 2.5, 2.5, 0.5, 4.5, 2.5, 0.5, 5, 2.5, 0.5, 4.5, 2.5, 0.5, 3.5, 2.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 4, 7, 5, 2, 8, 2), Cluster = structure(c(3L, 3L, 3L, 4L, 5L, 5L, 2L, 2L, 4L, 5L, 1L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 6L, 1L, 6L, 4L, 1L, 6L, 1L, 1L, 1L, 5L, 1L, 4L, 1L, 3L, 4L, 3L, 4L, 4L, 4L), .Label = c("1", "2", "3", "4", "5", "6"), class = "factor")), .Names = c("Location", "Lat", "Long", "SBD_ft", "SED_ft", "Cluster"), row.names = 5:41, class = "data.frame")
BBox<-c(-73.01, 47.28, -73.1, 47.30)
#Base <-get_map(BBox,zoom=13,source='google',maptype = 'hybrid')
Base_z <-get_map(BBox,zoom=15,source='google',maptype = 'hybrid')
fm0<-ggmap(Base_z,legend = "none",
base_layer=ggplot(aes(x=Long,y=Lat),data=pDat))
# Example subplots
ggplot(pDat,aes(ymin=SBD_ft,ymax=SED_ft,xmin=0,xmax=1,fill=Cluster))+
facet_wrap(~Location)+
geom_rect() +
scale_y_reverse()
# TEST 1, need to control size of subplots
ggplot(pDat)+
geom_subplot(aes(x=Long,y=Lat,group=Location,
subplot=geom_rect(data=pDat,aes(ymin=SBD_ft,ymax=SED_ft,xmin=0,xmax=1,fill=Cluster))))
# Final , does not work
fm0+
geom_subplot(aes(x=Long,y=Lat,group=Location,
subplot=geom_rect(data=pDat,aes(ymin=SBD_ft,ymax=SED_ft,xmin=0,xmax=1,fill=Cluster))))

Plot per species using a for-loop?

I have 9 plant species for which I want to plot a relationship. I have been plotting these the long way because I need to add text to the graphs individually. I have the 9 plots formatted to fit on one page in a 3x3 grid.
But is there a way to do this with a loop instead? And get the 9 plots formatted into 3x3? If this is possible, can you still add text to each plot?
I have code like this for all 9 but here are the first 2 species.
First I subset by species:
Acru<-carbon2[Species=="Acru",]
Arte<-carbon2[Species=="Arte",]
...
par(mfrow=c(3,3), cex=.3)
plot(LogRecBio~LogPreBiomass,data=Acru,font.lab=2,font.main=2, font.sub=3, mgp=c(2.5,1,0), cex.lab=2, cex.main=1.5, axes=F,lwd=1.5, cex=2.5, ann=F)
box()
axis(1,at=c(-2,-1,0,1,2,3,4),font=2,cex.axis=3)
axis(2,at=c(-5,-4,-3,-2,-1,0,1,2),font=2,cex.axis=3)
text(2,-0.27, sprintf("a) Acer rubrum"),font=3,cex=2.5)
text(2.35,-0.6,sprintf("R²= 0.18"),cex=2.5)
fit.bio.acru1 <- lm(LogRecBio ~LogPreBiomass, data=Acru, subset=c(Site=="7"))
abline(fit.bio.acru1, lwd=2, col='red')
fit.bio.acru2 <- lm(LogRecBio ~LogPreBiomass, data=Acru,subset=c(Site=="8"))
abline(fit.bio.acru2, lwd=2, col='blue')
fit.bio.acru
plot(LogRecBio~LogPreBiomass,data=Arte,font.lab=2,font.main=2, font.sub=3, mgp=c(2.5,1,0), cex.lab=2, cex.main=1.5, cex.axis=1.2,axes=F,lwd=1.5, cex=2.2, ann=F)
box()
axis(1,at=c(-3,-2,-1,0,1.0,2,3),font=2,cex.axis=3)
axis(2,at=c(-4,-3,-2,-1,0,1,2),font=2,cex.axis=3)
text(2.05,0.97, sprintf("b) Arundinaria tecta"),font=3,cex= 2.5)
text(2.56,0.59,sprintf("R² = 0.04"),cex= 2.5)
fit.bio.arte <- lm(LogRecBio ~LogPreBiomass, data=Arte)
abline(fit.bio.arte, lwd=2, col='red')
fit.bio.arte
Part of data frame carbon2:
structure(list(Treatment = c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), Species = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L), .Label = c("Acru", "Arte", "Clal", "Euro", "Gafr", "Ilgl",
"Lylu", "Oxar", "Pepu"), class = "factor"), Tag = c(64L, 248L,
249L, 250L, 251L, 252L, 253L, 315L, 316L, 318L, 931L, 932L, 933L,
934L, 935L, 936L, 3L, 4L, 5L, 6L, 917L, 918L, 919L, 920L, 921L,
923L, 924L, 995L, 996L, 997L, 208L, 209L, 210L, 211L, 212L, 213L,
214L, 215L, 323L, 324L, 925L, 926L, 927L, 928L, 929L, 930L, 987L,
988L, 989L, 990L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 51L,
52L, 912L, 913L, 914L, 915L, 916L, 59L, 60L, 62L, 63L, 240L,
901L, 902L, 903L, 904L, 905L, 907L, 908L, 909L, 22L, 23L, 937L,
938L, 939L, 976L, 977L, 979L, 980L, 981L, 985L, 986L), site = c(12L,
7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 23L, 23L, 23L, 23L, 23L,
23L, 16L, 16L, 16L, 16L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 16L,
16L, 16L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 23L, 23L, 23L,
23L, 23L, 23L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 12L, 12L, 23L, 23L, 23L, 23L, 23L, 12L, 12L, 12L, 12L,
7L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 12L, 12L, 23L, 23L,
23L, 16L, 16L, 16L, 16L, 16L, 16L, 16L), stem = c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), heightPre = c(58, 50, 38, 33, 28,
18, 20, 28, 47, 118, 109, 103, 99, 79, 69, 73, 54, 33, 32.5,
74, 67, 57, 77, 49, 45, 58, 89, 49, 33, 37, 69, 53, 64, 49, 70,
36, 59, 66.5, 21, 36.5, 59, 37, 59, 55, 33, 27, 35, 41, 65, 56,
37, 53, 73, 59, 16, 51, 37, 77, 79, 45, 68, 75, 110, 56, 115,
42, 90, 107, 86.5, 37, 113, 211, 130, 175, 135, 175, 122, 66,
115, 167, 84, 63.5, 144, 16, 51, 45, 54, 32, 70, 53), height1mo = c(0,
0, 0, 0, 0, 0, 0, 6, 10, 15, 25.5, 25, 26.5, 20, 19.5, 18, 19,
8.5, 20, 12, 7.5, 4, 7, 0, 4, 11, 3, 9, 3.5, 12.5, 10, 12.5,
19, 17.5, 11.5, 7, 12, 14, 18, 18, 3, 3.5, 6, 1, 9, 0.5, 7.5,
9, 17, 15, 1.5, 7.5, 14, 18, 5, 4.5, 6, 15.5, 15, 2, 0.5, 0,
12, 0, 5, 0, 0, 0, 0, 0, 37, 31, 14, 0, 20, 35, 0, 39, 0, 0,
21, 7, 12, 11, 23.5, 15, 26, 7, 5, 17), height2mo = c(2.5, 7.5,
9, 10, 12, 0, 8, 23, 34, 26.5, 57, 49, 57.5, 41, 43, 28, 29,
11, 29.5, 20, 21, 20, 10, 7, 11, 22.5, 13, 21, 17.5, 29.5, 24.5,
38, 53, 49, 44, 19, 38, 49, 37, 40, 10, 0, 18, 8.5, 19.5, 0.5,
9, 23, 29, 22, 6.5, 26, 36.5, 39, 15, 12.5, 13.5, 30, 45, 16.5,
2, 0, 14, 20, 43, 0.5, 1, 1, 0, 0, 86, 106, 59, 0, 67, 83, 32,
83, 3, 4.5, 49, 9.5, 43, 20, 35, 16, 27, 7, 7, 26.5), height4mo = c(7,
11.5, 10, 8.5, 17, 6.5, 8.5, 26, 34, 33, 62.5, 51.5, 61, 42.5,
46.5, 29, 30, 11.5, 26.5, 20, 23, 29, 11.5, 21, 12.5, 25, 15.5,
24, 28.5, 37, 51, 46, 60.5, 55, 53, 25, 49, 56, 40, 43, 23, 8,
16, 8.5, 19.5, 2.5, 9.5, 22.5, 21, 20, 6.5, 31, 42, 45, 15, 17.5,
13.5, 36.5, 47, 20, 13, 18, 20, 27.5, 70, 31, 21, 25, 42, 12,
89, 128, 64, 45, 69, 84.5, 32, 86, 31, 31, 50, 10, 49.5, 20,
42.5, 15, 38, 7.5, 13, 33), PreBiomass = c(3.895575649, 2.834165975,
1.573928396, 1.163246736, 0.817978445, 0.317316605, 0.39770427,
0.817978445, 2.48217785, 17.85049586, 12.66281683, 11.31037967,
10.45107234, 6.662611474, 5.086139353, 5.691293433, 3.119036919,
1.167754804, 1.13272457, 5.847881474, 5.365833116, 3.999508626,
6.910020728, 3.038057965, 2.602293243, 4.127993434, 8.991590789,
3.038057965, 1.480678454, 1.823048057, 2.062949335, 1.18423519,
1.760986422, 1.004008739, 2.126354774, 0.524854338, 1.483984987,
1.908835132, 0.168869468, 0.540308647, 5.375747945, 2.053683314,
5.375747945, 4.65118718, 1.622061536, 1.072373896, 1.831323212,
2.537878044, 6.564139518, 4.827265975, 2.156129781, 5.153936858,
11.20247906, 6.684694751, 0.282366443, 4.694933633, 2.156129781,
12.74952183, 13.56745754, 3.465912243, 7.799750512, 9.849322745,
24.51741906, 4.912423703, 27.25487445, 2.476234093, 15.20382114,
22.9550974, 13.83353724, 1.831101565, 33.25213131, 139.5296871,
45.87772104, 90.79892694, 50.03156249, 90.79892694, 39.65094302,
9.671283982, 34.61929294, 81.54741169, 26.00946401, 14.01849263,
85.55945731, 0.667045516, 8.637292691, 6.550744926, 9.799815468,
3.084543759, 17.38618089, 9.403377144), Biomass1mo = c(0, 0,
0, 0, 0, 0, 0, 0.030124963, 0.090031144, 0.214679983, 0.698192549,
0.67114866, 0.75387857, 0.430024245, 0.408844585, 0.348506855,
0.388198419, 0.078012828, 0.430024245, 0.155212563, 0.296240906,
0.112200441, 0.26629734, 0, 0.112200441, 0.535234264, 0.071949318,
0.39259111, 0.091290587, 0.652064296, 0.094858153, 0.142288516,
0.304507388, 0.262240101, 0.122283739, 0.04961378, 0.132115845,
0.174825154, 0.276013506, 0.276013506, 0.022723782, 0.030242664,
0.082163804, 0.002963157, 0.174263551, 0.000819511, 0.124274142,
0.174263551, 0.566729877, 0.449345809, 0.01811283, 0.21782346,
0.57145776, 0.842645845, 0.116410145, 0.09891947, 0.154294203,
0.668793517, 0.635749905, 0.028252321, 0.005400266, 0, 0.308521938,
0, 0.101231381, 0, 0, 0, 0, 0, 3.291544691, 2.308284799, 0.468693323,
0, 0.958429423, 2.944402977, 0, 3.658082992, 0, 0, 1.524728852,
0.19037959, 0.528356631, 0.448087868, 1.886696465, 0.806223299,
2.284810808, 0.19037959, 0.10066607, 1.021875261), Biomass2mo = c(0.00461379,
0.048598634, 0.071833216, 0.090031144, 0.133074246, 0, 0.055807842,
0.536596536, 1.24010478, 0.726931224, 3.474265098, 2.569451142,
3.535326978, 1.800572943, 1.980042107, 0.841402428, 0.902414303,
0.130479556, 0.933718887, 0.430024245, 1.453050159, 1.347577447,
0.461969077, 0.26629734, 0.535234264, 1.616437082, 0.6927849,
1.453050159, 1.09644076, 2.456139386, 0.483312867, 1.0729993,
1.964067221, 1.703060052, 1.400530346, 0.304507388, 1.0729993,
1.703060052, 1.0222427, 1.177817154, 0.211862783, 0, 0.630095648,
0.156738681, 0.730913281, 0.000819511, 0.174263551, 0.992673892,
1.525735605, 0.914132292, 0.174609348, 1.487410339, 2.512370265,
2.7832013, 0.635749905, 0.479653397, 0.540228204, 1.855529897,
3.472016487, 0.736631727, 0.031533874, 0, 0.375407219, 0.591122274,
1.566167617, 0.005400266, 0.013049571, 0.013049571, 0, 0, 17.86670522,
27.17489168, 8.39141448, 0, 10.82904112, 16.63862372, 2.460045699,
16.63862372, 0.021336774, 0.048116873, 7.586947075, 0.339458495,
5.924289588, 1.390158514, 4.011712305, 0.911037264, 2.454089599,
0.19037959, 0.19037959, 2.368736511), Biomass4mo = c(0.041918611,
0.121473174, 0.090031144, 0.063551149, 0.280731338, 0.035762566,
0.063551149, 0.697852512, 1.24010478, 1.163246736, 4.175122771,
2.837608296, 3.977614516, 1.934377716, 2.314568827, 0.902414303,
0.96555584, 0.142578593, 0.75387857, 0.430024245, 1.672251324,
2.392140111, 0.573271986, 1.453050159, 0.652064296, 1.902090818,
0.909034181, 1.785867231, 2.328738868, 3.484981432, 1.831472627,
1.518350095, 2.498057072, 2.100814509, 1.964067221, 0.501385136,
1.703060052, 2.170736601, 1.177817154, 1.343229421, 0.992673892,
0.140073002, 0.506470737, 0.156738681, 0.730913281, 0.016205216,
0.192640481, 0.953030318, 0.838582725, 0.766045551, 0.174609348,
1.951972553, 3.12089825, 3.472016487, 0.635749905, 0.806750379,
0.540228204, 2.512370265, 3.713345005, 0.991640221, 0.341613273,
0.516931045, 0.591122274, 0.886590001, 2.912202284, 1.032643803,
0.628997882, 0.785297256, 1.519953371, 0.308521938, 19.13863569,
39.66748749, 9.878452915, 4.874133229, 11.48709241, 17.24718389,
2.460045699, 17.86670522, 2.308284799, 2.308284799, 7.882847273,
0.374087949, 7.734229305, 1.390158514, 5.794509429, 0.806223299,
4.687787249, 0.21695254, 0.614836496, 3.588685645), PreCarbon = c(0.156967627,
0.122843082, 0.075813652, 0.059169491, 0.044340523, 0.020426006,
0.024570672, 0.043002708, 0.106999734, 0.545053086, 0.320308244,
0.290501628, 0.271291986, 0.183819859, 0.145631674, 0.160452129,
0.095815131, 0.041269875, 0.0402085, 0.164611233, 0.206240523,
0.161958253, 0.253981948, 0.129206528, 0.113781088, 0.166223479,
0.31553078, 0.129335339, 0.071711875, 0.085049069, 0.09317797,
0.056638382, 0.080836829, 0.04885422, 0.09574618, 0.027353778,
0.069332271, 0.086903123, 0.009475442, 0.026773874, 0.160707434,
0.070160311, 0.160707434, 0.141844012, 0.057277905, 0.04013973,
0.063665515, 0.084295725, 0.191213272, 0.146673529, 0.04757003,
0.100344991, 0.195222186, 0.125396417, 0.008354372, 0.092637319,
0.04757003, 0.218128582, 0.230401206, 0.07162901, 0.131269005,
0.157389096, 0.320282156, 0.091653711, 0.347792395, 0.054313153,
0.221509506, 0.305003004, 0.205854943, 0.043576888, 1.197871953,
3.518128126, 1.526275089, 2.548979546, 1.629080226, 2.548979546,
1.367623475, 0.472267765, 1.236694558, 2.352499024, 0.638415034,
0.362069714, 1.904909524, 0.022514492, 0.232778297, 0.18076034,
0.261297274, 0.090855905, 0.441867498, 0.25160457), X1moCarbon = c(0,
0, 0, 0, 0, 0, 0, 0.002996291, 0.00733127, 0.014924131, 0.027262412,
0.026357968, 0.02910929, 0.018027068, 0.017267076, 0.015069346,
0.016555346, 0.004223662, 0.018064917, 0.007582482, 0.025240181,
0.011434171, 0.023138557, 0, 0.011434171, 0.040903752, 0.007959618,
0.031793903, 0.009674612, 0.048110681, 0.007167162, 0.009865614,
0.017984257, 0.015981995, 0.00875496, 0.004302588, 0.009305238,
0.011605185, 0.015676514, 0.015676514, 0.001435067, 0.001828411,
0.004266066, 0.000255474, 0.008072101, 8.6e-05, 0.006067683,
0.008083206, 0.022002661, 0.018064652, 0.000900408, 0.009931103,
0.025212867, 0.036698014, 0.005423393, 0.004634604, 0.007118678,
0.029351971, 0.028106107, 0.001391831, 0.000170474, 0, 0.00861976,
0, 0.002921775, 0, 0, 0, 0, 0, 0.145554027, 0.112095861, 0.034715829,
0, 0.058726823, 0.134088229, 0, 0.157321152, 0, 0, 0.046764496,
0.007082034, 0.017870499, 0.015406694, 0.056813876, 0.026251236,
0.067611463, 0.007089935, 0.003979541, 0.032552937), X2moCarbon = c(0.000649991,
0.004515538, 0.006213783, 0.007472947, 0.010284713, 0, 0.005055737,
0.031163252, 0.061950899, 0.03996902, 0.104905954, 0.080952912,
0.106489463, 0.0596727, 0.064736059, 0.031121663, 0.033108443,
0.006368256, 0.034087686, 0.017584511, 0.090428862, 0.085023956,
0.035457668, 0.022619457, 0.039985244, 0.098665234, 0.04936287,
0.090524095, 0.071905993, 0.139112044, 0.01893176, 0.035575351,
0.057471358, 0.051317148, 0.043939693, 0.013147169, 0.035575351,
0.051317148, 0.032779136, 0.036681952, 0.010956757, 0, 0.027658897,
0.008484002, 0.031380578, 9.89e-05, 0.009296871, 0.040783331,
0.058816936, 0.038019773, 0.008653254, 0.068600624, 0.113960148,
0.125843837, 0.030152569, 0.022965412, 0.025762347, 0.084974223,
0.156538314, 0.034969776, 0.000617961, 0, 0.006829998, 0.010617342,
0.027416033, 0.000112755, 0.000265127, 0.000265127, 0, 0, 0.893643875,
1.221422984, 0.50961417, 0, 0.615827082, 0.847505481, 0.205500657,
0.847505481, 0.006343264, 0.011521572, 0.304122678, 0.017974685,
0.242561906, 0.064815574, 0.170213577, 0.04413614, 0.108738758,
0.010654473, 0.010654473, 0.105287901), X4moCarbon = c(0.003939148,
0.009545784, 0.007472947, 0.005621946, 0.018936017, 0.003514856,
0.005621946, 0.038653227, 0.061950899, 0.058780944, 0.122873324,
0.088156055, 0.117853953, 0.063453978, 0.074010607, 0.03304018,
0.035078824, 0.006867286, 0.028392571, 0.017584511, 0.101443992,
0.135990762, 0.042290614, 0.090428862, 0.046980199, 0.112718863,
0.061628519, 0.10716323, 0.133173424, 0.185313121, 0.054366886,
0.046847602, 0.069583598, 0.060629528, 0.057471358, 0.019488753,
0.051317148, 0.062228442, 0.036681952, 0.040720029, 0.040718675,
0.007712115, 0.022971487, 0.008484002, 0.031380578, 0.001238836,
0.010122608, 0.039392597, 0.035328505, 0.032710879, 0.008653254,
0.089246941, 0.140615722, 0.155927128, 0.030152569, 0.037960536,
0.025762347, 0.113960148, 0.167057162, 0.046603193, 0.006232079,
0.009319662, 0.010617342, 0.01574909, 0.050249507, 0.018386847,
0.011359619, 0.014091865, 0.026775581, 0.005739173, 0.940599218,
1.618014419, 0.57521217, 0.340713733, 0.643414594, 0.870471728,
0.205500657, 0.893643875, 0.198091533, 0.198091533, 0.314956518,
0.01963135, 0.309519324, 0.064815574, 0.23812921, 0.039496022,
0.196215504, 0.011995076, 0.030876347, 0.153759364), TotalCarbon = c(2.501938424,
2.332218951, 1.641013423, 1.392483377, 1.696000406, 0.411835774,
0.764726634, 3.251928154, 6.361282467, 11.96169249, 13.62052751,
11.04045665, 12.83366357, 7.61659474, 7.576922118, 5.024502369,
4.227801803, 1.174993138, 3.259824259, 3.901744082, 10.5848291,
10.50668723, 7.021121066, 5.668839356, 5.08697083, 10.92840985,
8.922540693, 9.705419805, 8.451769698, 13.81683185, 3.988112769,
4.003878786, 6.156035357, 5.100700715, 5.268944019, 1.651130691,
4.319967871, 5.653749527, 2.952799027, 3.509044554, 4.146751849,
1.311194265, 4.40839747, 2.767792413, 3.333793425, 0.645000544,
1.768035403, 4.402711785, 6.904856277, 5.163288885, 1.376050648,
7.418577716, 12.65320411, 12.77220297, 2.468109142, 3.631338446,
2.75250667, 10.95485279, 15.93354872, 4.067048349, 2.1863628,
2.640426289, 5.559398908, 2.325058743, 8.001919262, 1.371376664,
3.675361853, 5.009731732, 3.891091568, 0.825828495, 88.5833406,
157.9578266, 63.60386651, 48.45610517, 72.33176226, 104.4979151,
35.92690142, 74.39089664, 24.77861122, 41.74870207, 33.41190899,
6.935077567, 49.04256584, 5.429985864, 19.14736986, 6.276180599,
15.71334028, 2.308491154, 8.093447265, 13.61309907), OLDestAssim = c(0.16273292,
0.531283865, 0.546784515, 0.548005831, 1.117252104, 0.114703735,
0.430112005, 2.958994249, 5.413171027, 4.46316534, 10.53485645,
8.109549494, 10.50791092, 5.898234837, 6.492409411, 3.283621134,
3.499740655, 0.718250337, 3.370987696, 1.789036071, 8.664887392,
9.086176264, 3.919440166, 4.123497491, 3.919792348, 9.950535196,
4.756772076, 9.060767572, 8.278498547, 14.54720467, 4.724107286,
5.766516948, 9.027313298, 7.989111013, 6.951312225, 2.28863022,
5.981065361, 7.901084227, 5.4728181, 6.020818486, 1.853280059,
0.311044291, 2.18794981, 0.68034361, 2.765418329, 0.047128668,
0.980573348, 3.453418537, 4.673671847, 3.476060731, 0.646316335,
5.778390351, 9.633196576, 10.92370219, 2.319186273, 2.209960947,
2.058639203, 7.773645484, 12.22756086, 2.852689634, 0.386565881,
0.496860166, 1.407968874, 1.680611096, 4.916640727, 0.977215919,
0.620253347, 0.763829673, 1.409081851, 0.302135427, 44.7470637,
63.92221417, 24.86052444, 6.076027823, 29.59811425, 41.96954834,
9.196665562, 43.0963223, 3.680815508, 3.819136463, 19.30141334,
1.332232454, 16.07431445, 4.286639367, 13.30975772, 3.365326795,
10.62150582, 0.898527189, 1.227305975, 8.317751517), CARBONmulti = c(2.621415393,
2.398836005, 1.641013423, 1.392483377, 1.696000406, 0.411835774,
0.809806973, 3.251928154, 6.361282467, 11.96169249, 13.62052751,
11.04045665, 12.83366357, 7.61659474, 7.576922118, 5.024502369,
4.227801803, 1.174993138, 4.510076237, 3.901744082, 18.5717312,
10.50668723, 7.021121066, 8.059558949, 5.08697083, 10.92840985,
11.70126006, 16.07362835, 9.527447818, 21.36601039, 4.377265297,
4.003878786, 6.156035357, 6.514095673, 5.268944019, 2.169858768,
4.319967871, 5.653749527, 2.952799027, 4.588995837, 4.705122057,
1.542557708, 6.195249968, 2.767792413, 3.480946773, 0.645000544,
1.768035403, 4.961955587, 6.904856277, 5.163288885, 1.765904086,
7.418577716, 12.65320411, 12.77220297, 2.468109142, 3.631338446,
3.441469031, 15.95980398, 15.93354872, 4.067048349, 2.1863628,
2.640426289, 6.723791976, 2.325058743, 8.001919262, 1.857730159,
3.675361853, 5.330578088, 3.891091568, 0.825828495, 88.5833406,
157.9578266, 63.60386651, 48.45610517, 82.73192555, 106.3419007,
35.92690142, 74.66251592, 24.77861122, 41.74870207, 35.0178608,
6.935077567, 49.04256584, 5.429985864, 19.14736986, 6.276180599,
23.40428597, 2.308491154, 8.093447265, 13.61309907), RecBiomass = c(0.010760569,
0.042860289, 0.05720155, 0.054632562, 0.343201388, 0.112703103,
0.159794989, 0.853142911, 0.499603516, 0.065166074, 0.329715167,
0.250885327, 0.380593913, 0.290333261, 0.455073813, 0.158560495,
0.309568583, 0.122096345, 0.665544467, 0.073535048, 0.311648031,
0.598108502, 0.082962412, 0.478282566, 0.25057295, 0.460778547,
0.10109826, 0.587831849, 1.572751236, 1.911623458, 0.887793314,
1.282135599, 1.418555556, 2.092426518, 0.923678046, 0.955284351,
1.1476262, 1.137204866, 6.974719413, 2.48604095, 0.184657819,
0.068205746, 0.094214004, 0.03369864, 0.450607616, 0.015111536,
0.105191962, 0.375522504, 0.127752118, 0.158691391, 0.080982764,
0.378734278, 0.278589965, 0.519397911, 2.25150658, 0.171834246,
0.250554586, 0.197056039, 0.273694979, 0.286112328, 0.043797974,
0.052483918, 0.024110298, 0.180479139, 0.106850695, 0.417021883,
0.041371039, 0.034210147, 0.109874528, 0.168489801, 0.575561173,
0.284294248, 0.215321352, 0.053680516, 0.229596915, 0.189949204,
0.062042552, 1.847397435, 0.066676255, 0.028306046, 0.303076114,
0.026685319, 0.09039596, 2.084053457, 0.670871028, 0.123073529,
0.478354645, 0.070335374, 0.035363517, 0.381637957), RecovCarbonMULTI = c(0.672921188,
0.846399267, 1.042622667, 1.197066224, 2.073404766, 1.297870225,
2.03620387, 3.975567052, 2.562782706, 0.670104214, 1.075631725,
0.976134929, 1.227975767, 1.143184586, 1.489719725, 0.882840154,
1.355483091, 1.006198505, 3.981617736, 0.667206423, 3.461108611,
2.626994517, 1.016078148, 2.65286543, 1.954803074, 2.647390319,
1.301355937, 5.290757627, 6.434515065, 11.7199381, 2.121848182,
3.380982781, 3.495788088, 6.488086629, 2.477923291, 4.134211359,
2.911059012, 2.961884676, 17.4856892, 8.493285951, 0.875249752,
0.751117613, 1.15244428, 0.595072248, 2.146001675, 0.601469829,
0.965441486, 1.955159193, 1.051905777, 1.069609363, 0.819015674,
1.439400194, 1.129500358, 1.910663604, 8.740801894, 0.773458952,
1.596132599, 1.251796278, 1.174394589, 1.173442391, 0.280311889,
0.268082015, 0.274245505, 0.473301752, 0.293595895, 0.750223965,
0.241739351, 0.23221762, 0.281279582, 0.451000923, 2.663989859,
1.132073252, 1.386378073, 0.533663853, 1.65359468, 1.171180148,
0.906079369, 7.72002105, 0.715745734, 0.511956188, 1.346350728,
0.494709221, 0.573198655, 8.14035284, 2.216825404, 0.958086549,
2.388237416, 0.748406032, 0.465510357, 1.447681919), LogRespBiomass = c(-3.172025374,
-2.108061831, -2.407599624, -2.755910201, -1.27035716, -3.330853575,
-2.755910201, -0.359747499, 0.215195876, 0.151215006, 1.429143764,
1.042961548, 1.380682272, 0.659785681, 0.839223418, -0.102681548,
-0.035051343, -1.947861901, -0.282523972, -0.843913688, 0.514170817,
0.872188409, -0.556395005, 0.373664905, -0.427612108, 0.642953712,
-0.095372583, 0.579904141, 0.845326863, 1.248462716, 0.605120357,
0.417624281, 0.915513259, 0.742325131, 0.675017436, -0.690380739,
0.532426664, 0.775066557, 0.163662856, 0.29507673, -0.007353076,
-1.965591549, -0.680288732, -1.853175313, -0.313460457, -4.122422113,
-1.64692962, -0.048108563, -0.176042044, -0.266513645, -1.745204097,
0.668840427, 1.138120861, 1.244735545, -0.452950024, -0.214740978,
-0.615763629, 0.921226636, 1.311933089, -0.008394918, -1.074075962,
-0.659845789, -0.52573239, -0.120372635, 1.068909594, 0.032122313,
-0.46362739, -0.241692963, 0.418679657, -1.175962326, 2.951709103,
3.680531897, 2.290355912, 1.583942289, 2.441224006, 2.847648877,
0.900179927, 2.882938937, 0.836504737, 0.836504737, 2.064689168,
-0.983264351, 2.045655842, 0.329417779, 1.756910819, -0.215394529,
1.544960669, -1.528076659, -0.486398907, 1.27778602), LogPreBiomass = c(1.35984146,
1.041747705, 0.453574657, 0.151215006, -0.200919294, -1.14785525,
-0.92204659, -0.200919294, 0.90913634, 2.882031287, 2.53866989,
2.425720859, 2.346704589, 1.896511521, 1.626519066, 1.738937539,
1.137524274, 0.155082934, 0.124625855, 1.766079454, 1.680051651,
1.38617151, 1.932972637, 1.111218484, 0.956393073, 1.417791438,
2.196289784, 1.111218484, 0.392500398, 0.600509857, 0.724136675,
0.169097157, 0.565874119, 0.004000725, 0.75440914, -0.644634506,
0.394731028, 0.646493177, -1.778629241, -0.615614734, 1.681897717,
0.719634919, 1.681897717, 1.537122495, 0.483697893, 0.069874785,
0.605038772, 0.931328316, 1.881621428, 1.574280257, 0.768314847,
1.639760861, 2.416135098, 1.899820548, -1.264549608, 1.546483977,
0.768314847, 2.545493767, 2.607674097, 1.242975872, 2.054091748,
2.287402696, 3.199383847, 1.591767446, 3.305232384, 0.906738895,
2.721546787, 3.133540021, 2.627095879, 0.604917734, 3.504118865,
4.938277389, 3.825979619, 4.508647468, 3.912654056, 4.508647468,
3.680114731, 2.269161081, 3.544411126, 4.40118459, 3.258460472,
2.64037736, 4.449211541, -0.404896996, 2.156089188, 1.879578772,
2.282363556, 1.126403756, 2.855675689, 2.241068895), LogRecBio = c(-4.531866845,
-3.149809546, -2.861174283, -2.9071252, -1.069437867, -2.182998325,
-1.833863604, -0.158828206, -0.693940463, -2.730816283, -1.109526128,
-1.382759309, -0.966022317, -1.23672584, -0.787295647, -1.841619087,
-1.172575619, -2.102944833, -0.407149826, -2.609993143, -1.165880834,
-0.5139831, -2.489367641, -0.737553579, -1.384005183, -0.774837727,
-2.291662364, -0.531314343, 0.452826465, 0.647952859, -0.119016318,
0.248527124, 0.34963914, 0.738324406, -0.079391703, -0.045746233,
0.137695635, 0.12857338, 1.942292099, 0.910691465, -1.689250794,
-2.685226465, -2.362186446, -3.390297799, -0.797158349, -4.192296853,
-2.251968388, -0.979436879, -2.057663471, -1.8407939, -2.513518937,
-0.970920433, -1.278014238, -0.655085002, 0.811599583, -1.761224953,
-1.384078474, -1.624267129, -1.295741008, -1.25137079, -3.128167718,
-2.94724848, -3.725116227, -1.712140081, -2.236322793, -0.874616581,
-3.185174184, -3.375232983, -2.208416219, -1.780880059, -0.552409761,
-1.257745493, -1.535623706, -2.924705174, -1.471430051, -1.66099859,
-2.779934807, 0.613777857, -2.707906386, -3.564679858, -1.193771304,
-3.623641715, -2.403555703, 0.734314775, -0.399178369, -2.094973305,
-0.737402886, -2.65448042, -3.342074583, -0.963282876), LogCarbAss = c(0.963714398,
0.874983622, 0.495313992, 0.331088755, 0.528272777, -0.887130616,
-0.210959365, 1.179248099, 1.850230003, 2.481709251, 2.611578031,
2.401566403, 2.552071685, 2.030329385, 2.025107064, 1.614326418,
1.44168219, 0.161262308, 1.506314057, 1.361423654, 2.921640597,
2.352011933, 1.948922901, 2.086858834, 1.626682532, 2.391365807,
2.459696533, 2.777179938, 2.254176877, 3.06180136, 1.476424168,
1.387263588, 1.817432959, 1.873968394, 1.661829967, 0.774662082,
1.463247965, 1.732318958, 1.082753543, 1.523661228, 1.548651715,
0.433441888, 1.823782864, 1.01805004, 1.247304318, -0.438504119,
0.569868988, 1.601799935, 1.932224972, 1.641573757, 0.568662789,
2.003987356, 2.537910472, 2.547271167, 0.903452328, 1.289601298,
1.235898424, 2.77007331, 2.768426869, 1.402917515, 0.782239341,
0.970940377, 1.905652278, 0.843745305, 2.079681421, 0.619355398,
1.301651591, 1.673459692, 1.358689727, -0.19136816, 4.483943811,
5.062328077, 4.152674263, 3.88065834, 4.415605568, 4.666659382,
3.581486358, 4.312978171, 3.20998083, 3.731668363, 3.55585824,
1.936592239, 3.892688612, 1.691936531, 2.952165362, 1.836761611,
3.152919167, 0.836594131, 2.091054755, 2.611032496), LogRecCarb = c(-0.396127062,
-0.166764084, 0.041739334, 0.17987375, 0.729192071, 0.260724633,
0.711087226, 1.380167393, 0.941093663, -0.400322035, 0.07290814,
-0.024154455, 0.205367096, 0.133817864, 0.398587998, -0.124611121,
0.304157916, 0.006179373, 1.381688203, -0.404655801, 1.241588946,
0.965840424, 0.015950264, 0.97564035, 0.670289459, 0.973574369,
0.263406749, 1.665961454, 1.861676479, 2.461291503, 0.752287493,
1.218166431, 1.25155884, 1.869967669, 0.907420827, 1.419296587,
1.068516937, 1.085825781, 2.861382786, 2.139275963, -0.133246002,
-0.286193031, 0.141885148, -0.519072456, 0.763606425, -0.508378904,
-0.035169784, 0.670471619, 0.050603545, 0.067293501, -0.199652057,
0.364226495, 0.121775374, 0.647450618, 2.168001935, -0.256882678,
0.467583578, 0.224579542, 0.160752771, 0.159941643, -1.271852406,
-1.316462319, -1.29373157, -0.74802214, -1.225550964, -0.287383497,
-1.419895195, -1.46008033, -1.268406151, -0.796285893, 0.979824946,
0.124050688, 0.326694644, -0.627989127, 0.502951512, 0.158011914,
-0.098628373, 2.043817091, -0.334430295, -0.669516228, 0.297397768,
-0.703785121, -0.55652293, 2.096833526, 0.796076174, -0.042817162,
0.870555611, -0.289809625, -0.764620933, 0.369963601)), .Names = c("Treatment",
"Species", "Tag", "site", "stem", "heightPre", "height1mo", "height2mo",
"height4mo", "PreBiomass", "Biomass1mo", "Biomass2mo", "Biomass4mo",
"PreCarbon", "X1moCarbon", "X2moCarbon", "X4moCarbon", "TotalCarbon",
"OLDestAssim", "CARBONmulti", "RecBiomass", "RecovCarbonMULTI",
"LogRespBiomass", "LogPreBiomass", "LogRecBio", "LogCarbAss",
"LogRecCarb"), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 46L,
47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 105L, 106L, 107L,
108L, 109L, 110L, 111L, 112L, 113L, 114L, 123L, 124L, 125L, 126L,
127L, 128L, 129L, 130L, 131L, 132L, 172L, 173L, 174L, 175L, 176L,
177L, 178L, 179L, 180L, 181L, 227L, 228L, 229L, 230L, 231L, 232L,
233L, 234L, 235L, 236L, 255L, 256L, 257L, 258L, 259L, 260L, 261L,
262L, 263L, 264L, 290L, 291L, 292L, 293L, 294L, 295L, 296L, 297L,
298L, 299L), class = "data.frame")
This should work with the simple graphics package. You need to add the real scientific names, in the same order as they are listed in species. If you want a different order, you can manually set the species too.
species = unique(carbon2$Species) # c("Acru", "Arte", ...)
bin.name = c("Acer rubrum", "Arundinaria tecta", "Clethra alnifolia",
"Eupatorium rotundifolium", "Gaylussacia frondosa",
"Ilex glabra", "Lyonia lucida", "Oxydendrum arboreum",
"Persea palustris")
sites = c(7,8) # sites to use
color = c("blue", "green") # colors for each site
fit.bio = list() # list to save all models
par(mfrow=c(3,3), cex=.3)
for(isp in seq_along(species)) {
sp.data = carbon2[carbon2$Species==species[isp], ]
fit.bio[[isp]] <- lm(LogRecBio ~ LogPreBiomass, data=sp.data)
sp.label = paste(letters[isp], ") ", bin.name[isp], sep="")
sp.r.squared = paste("R²", "=", round(summary(fit.bio[[isp]])$adj.r.squared, 3))
plot(LogRecBio ~ LogPreBiomass, data=sp.data,
font.lab=2,font.main=2, font.sub=3, ylim=c(-5,4),
mgp=c(2.5,1,0), cex.lab=2, cex.main=1.5,
axes=FALSE, lwd=1.5, cex=2.5, ann=FALSE)
for(isite in seq_along(sites)) {
# loop for each selected site
site.data = sp.data[sp.data$site==sites[isite], ]
site.model = lm(LogRecBio ~ LogPreBiomass, data=site.data)
abline(site.model, lwd=2, col=color[isite])
}
abline(fit.bio[[isp]], lwd=2, col='red') # all data
axis(1,at=c(-2,-1,0,1,2,3,4),font=2,cex.axis=3)
axis(2,at=c(-5,-4,-3,-2,-1,0,1,2),font=2,cex.axis=3)
box()
mtext(sp.label, 3, line=-2.5, adj=0.05, font=3, cex=0.75)
mtext(sp.r.squared, 3, line=-2.5, adj=0.95, cex=0.75)
}
In reply to the comments, this is how your code would look like if you used ggplot2.
DF<-read.csv("test.csv")
require(ggplot2)
qplot(data=DF,x=LogPreBiomass,y=LogRecBio,facets=~Species)
I saved your sample as a .csv file named test.csv.Does this work for you?

Resources