簡體   English   中英

如何完善以下R圖?

[英]How do I perfect the following R plot?

我在R中有以下情節:

x = c(0, 1e-10, 1e-08, 1e-06, 1e-05, 0.001, 0.1);
y = c(22000, 21490, 17252, 9204, 6118, 5092, 4998);
z = c(85.59, 85.59, 85.58, 85.49, 85.29, 85.29, 85.29);

x1 = c(0, 1e-10, 1e-08, 1e-06, 1e-05, 0.001, 0.1);
y2 = c(22000, 20039, 15185, 7705, 5436, 5223, 4933);
z2 = c(85.59, 85.59, 85.58, 85.53, 85.46, 85.49, 85.49);

y = y / 60;

y2 = y2 / 60;


x = log(x);

par("mar")
par(mar = c(par("mar")[1:3], 5.1))

plot(x,y, type="n", lwd=4, ylab="", xlab="threshold", xaxt="n",yaxt="n")

axis(1,lwd=4)
axis(2,lwd=4)

points(x, y, type = "l", lwd=4)

points(x, y, col="red", cex=2, pch=19)

points(x, y2, lwd=4, type="o", lty=2, col="black");

points(x, y2, col="red", cex=2, pch=19);

par("usr")
par(usr = c(par("usr")[1:2], 84,86))

axis(4, lwd=4)
points(x, z, type="l", lwd=4)

points(x, z, col="blue", cex=2, pch=15)

points(x, z2, type="l", col="black", lty=2, lwd=4)

points(x, z2, col="blue", cex=2, pch=15)


mtext("Measure1", side = 4, col = "blue",line=3)
mtext("Measure2", side = 2, col = "red",line=3)

這對我來說幾乎是完美的,但是我只想根據以下幾點進行調整:

  1. 左側的y軸和x軸-較粗,但是由於某些原因,粗體部分並未在所有軸上伸展。

  2. 我想將數字和標簽的字體做大一些,也許用粗體顯示。

  3. 我什至可能要將字體更改為Times,但是從網上看到的內容來看,這聽起來很麻煩。

謝謝!

正如@thelatemail在上面的評論中提到的那樣,您的第一個問題可以通過功能box回答:

box(lwd=4)

如果只希望軸的側面為粗體,則需要添加bty參數:

box(lwd=4, bty="u") # For all the different kind of boxes see ?par.

要更改字體和標簽的大小,必須在plotaxis語句中使用參數fontcex.labcex.axis

axis(1, font=2, cex.axis=1.1) #font=2 correspond to bold face. See ?par for more information

最后,對於字體,您可以使用參數family ,但是它與各種輸出設備的工作方式不同。 您可以在?x11 “字體”部分和此答案中找到有關該主題的更多信息。

axis(1, family="Times") #This will work with Cairo devices for example.

這是將cex.axis設置為1.1,粗體和U形框以及Times字體的圖: 在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM