我正在繪製兩個羣體中每個個體測得的兩個同位素的相關係數(值= 0.0:1.0)。我希望我的散點圖具有固定的縱橫比,這樣無論圖形設備如何,x軸和y軸都是完全相同的尺寸。建議?如何定義散點圖的固定高寬比
這是我在R的第一個情節,任何意見對我的代碼的改進表示讚賞?最後,值得投資學習基本的繪圖技術,還是應該跳轉到ggplot2或lattice?
我的劇情腳本:
## Create dataset
WW_corr <-
structure(list(South_N15 = c(0.7976495, 0.1796725, 0.5338347,
0.4103769, 0.7447027, 0.5080296, 0.7566544, 0.7432026, 0.8927161
), South_C13 = c(0.76706752, 0.02320767, 0.88429902, 0.36648357,
0.73840937, 0.0523504, 0.52145159, 0.50707858, 0.51874445), North_N15 = c(0.7483608,
0.4294148, 0.9283554, 0.8831571, 0.5056481, 0.1945943, 0.8492716,
0.5759033, 0.7483608), North_C13 = c(0.08114805, 0.47268136,
0.94975596, 0.06023815, 0.33652839, 0.53055943, 0.30228833, 0.8864435,
0.08114805)), .Names = c("South_N15", "South_C13", "North_N15",
"North_C13"), row.names = c(NA, -9L), class = "data.frame")
opar <- par()
## Plot results
par(oma = c(1, 0, 0, 0), mar = c(4, 5, 2, 2))
plot(1,1,xlim=c(0:1.0), ylim=c(0:1.0), type="n", las=1, bty="n", main = NULL,
ylab=expression(paste("Correlation Coefficient (r) for ", delta ^{15},"N ",
"\u0028","\u2030","\u0029")),
xlab=expression(paste("Correlation Coefficient (r) for ", delta ^{13},"C ",
"\u0028","\u2030","\u0029")))
points(WW_corr$South_N15, WW_corr$South_C13, pch = 23, cex = 1.25,
bg ="antiquewhite4", col = "antiquewhite4")
points(WW_corr$North_N15, WW_corr$North_C13, pch = 15, cex = 1.25,
bg ="black")
axis(1, at = seq(0, 1.0, by = 0.1), labels = F, tick = TRUE, tck = -0.01)
axis(2, at = seq(0, 1.0, by = 0.1), labels = F, tick = TRUE, tck = -0.01)
abline(h=.86, v=.86, col = "gray60", lty = 2)
legend("topleft", c("North", "South"), pch = c(15, 23),
col = c("black", "antiquewhite4"), pt.bg = c("black", "antiquewhite4"),
horiz=TRUE, bty = "n")
par(opar)
是的,照我說的做,而不是我做的:-),並學習'ggplot'。 – 2012-01-01 15:09:45
你已經清楚地瞭解了基礎圖形的基礎知識,所以我建議至少感受一下ggplot2/lattice,因爲考慮到這個問題的質量,它不會是一個巨大的時間投資。他們很不一樣,但你會很快接受他們。一旦你瞭解了每一種語言的一般語法+流程,你就可以決定哪一個你想花大部分時間。但是對每一個都有基本的瞭解是非常值得的。 – joran 2012-01-01 18:06:14