fbielejec
unread,Dec 7, 2012, 5:06:30 AM12/7/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggp...@googlegroups.com
Can I reduce the spacing between factor levels on this plot? I feel like I'm loosing a lot of space here:
results = structure(list(patient = structure(c(8L, 7L, 6L, 5L, 4L, 3L,
2L, 1L, 8L, 8L, 7L, 7L, 6L, 6L, 5L, 5L, 4L, 4L, 3L, 3L, 2L, 2L,
1L, 1L), .Label = c("patient9", "patient8", "patient7", "patient6",
"patient5", "patient3", "patient2", "patient1"), class = "factor"),
time = c(93857, 170821, 75388, 134944, 78373, 116634, 101784,
81854, 98009.104, 98009.104, 360038, 360038, 77133.555, 77133.555,
153232.884, 153232.884, 108250.948, 108250.948, 166773.6,
166773.6, 148614, 148614, 84381.62, 84381.62), seed = c(124L,
125L, 126L, 128L, 129L, 130L, 131L, 132L, 124L, 124L, 125L,
125L, 126L, 126L, 128L, 128L, 129L, 129L, 130L, 130L, 131L,
131L, 132L, 132L), statistic = structure(c(2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 7L, 8L, 7L, 8L, 7L, 8L, 7L, 8L, 7L, 8L, 7L,
8L, 7L, 8L, 7L, 8L), .Label = c("kappa", "omega", "clock.rate",
"kappa.1", "kappa.2", "likelihood", "omega.1", "omega.2",
"treeModel.rootHeight"), class = "factor"), mean = c(0.439,
0.9031, 0.9414, 0.4762, 0.4557, 1.2688, 0.6457, 1.423, 0.2541,
0.542, 0.4835, 1.0372, 0.6686, 1.0013, 0.5214, 0.4755, 0.1717,
0.5728, 0.7833, 1.5712, 0.5383, 0.7041, 0.8742, 1.4518),
stdErr = c(0.0518, 0.0789, 0.1293, 0.0475, 0.0638, 0.1229,
0.058, 0.1689, 0.0552, 0.0746, 0.0839, 0.0999, 0.2195, 0.1517,
0.1572, 0.0495, 0.0524, 0.0866, 0.1202, 0.1885, 0.0847, 0.0752,
0.4383, 0.1773), median = c(0.436, 0.8995, 0.9319, 0.4739,
0.4502, 1.2628, 0.643, 1.4128, 0.2487, 0.5369, 0.475, 1.0309,
0.6343, 0.9893, 0.5002, 0.4733, 0.1651, 0.5652, 0.7721, 1.5557,
0.5317, 0.7002, 0.7772, 1.4398), hpdLower = c(0.3419, 0.749,
0.7002, 0.3879, 0.3323, 1.0417, 0.5412, 1.0971, 0.1534, 0.4026,
0.3334, 0.8467, 0.298, 0.7156, 0.2563, 0.3793, 0.0785, 0.4121,
0.5626, 1.2157, 0.3762, 0.5626, 0.226, 1.1259), hpdUpper = c(0.5422,
1.0546, 1.2008, 0.5714, 0.5805, 1.5189, 0.7663, 1.7493, 0.362,
0.6927, 0.6539, 1.2362, 1.1023, 1.3024, 0.8386, 0.5711, 0.2753,
0.7431, 1.0248, 1.9354, 0.7033, 0.8528, 1.7186, 1.809), ESS = c(1126.9402,
342.0793, 813.8333, 491.1194, 633.3413, 391.2292, 747.8335,
1023.0436, 977.7185, 832.8171, 437.3496, 321.5035, 4123.2971,
489.0813, 885.3977, 551.1583, 457.2999, 905.8711, 2799.957,
165.2728, 820.8626, 628.7446, 2729.5149, 1224.65), analysis = c("Homogenous",
"Homogenous", "Homogenous", "Homogenous", "Homogenous", "Homogenous",
"Homogenous", "Homogenous", "Epoch", "Epoch", "Epoch", "Epoch",
"Epoch", "Epoch", "Epoch", "Epoch", "Epoch", "Epoch", "Epoch",
"Epoch", "Epoch", "Epoch", "Epoch", "Epoch")), .Names = c("patient",
"time", "seed", "statistic", "mean", "stdErr", "median", "hpdLower",
"hpdUpper", "ESS", "analysis"), row.names = c("1", "3", "5",
"7", "9", "11", "13", "15", "12", "2", "8", "91", "151", "16",
"22", "23", "29", "30", "36", "37", "43", "44", "50", "51"), class = "data.frame")
xmin = with(results, min(mean[ c(statistic == 'omega.1' | statistic == 'omega.2' | statistic == 'omega') ] ) )
xmax = with(results, max(mean[ c(statistic == 'omega.1' | statistic == 'omega.2' | statistic == 'omega') ] ) )
dodge = 0.2
p <- ggplot(results)
p <- p + aes(x = seq(x = xmin, xmax, length.out = 100))
p <- p + geom_linerange(aes(ymin = hpdLower, ymax = hpdUpper, x = patient, color = statistic), size = 1.2, width = .75, position = position_dodge(width = dodge))
p <- p + geom_point(aes(y = mean, x = patient, color = statistic, ymax = 0), size = 2.5, position = position_dodge(width = dodge))
p <- p + scale_x_discrete(
breaks = c("patient1", "patient2", "patient3", "patient5", "patient6", "patient7", "patient8", "patient9"),
labels = c("patient 1", "patient 2", "patient 3", "patient 5", "patient 6", "patient 7", "patient 8", "patient 9")
)
p <- p + xlab(NULL)
p <- p + scale_y_continuous(expression(omega))
p <- p + coord_flip()
p <- p + theme_bw()
p <- p + theme( legend.position = "top",
legend.justification = "center")
# p <- p + facet_grid(. ~ analysis)
p <- p + scale_colour_grey(
name = "Statistic",
breaks = c("omega", "omega.1", "omega.2"),
labels = c(expression(omega), expression(omega[1]), expression(omega[2]))
)
print(p)