楼主: 苏谷壳
5515 8

[问答] R作图 怎么把图例放在四个图片中间 [推广有奖]

  • 1关注
  • 0粉丝

本科生

70%

还不是VIP/贵宾

-

威望
0
论坛币
23 个
通用积分
3.7941
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1151 点
帖子
63
精华
0
在线时间
85 小时
注册时间
2016-1-3
最后登录
2021-6-29

楼主
苏谷壳 发表于 2017-8-18 16:48:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如图所示,想把图例放在四个图片对角线即整张图片的正中间位置,怎么办

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:如图所示 怎么办 对角线

Rplot01.png (8.26 KB)

Rplot01.png

沙发
deem 学生认证  发表于 2017-8-18 16:58:01
  1. legend('content', xjust=0.5, yjust=0.5)
复制代码

藤椅
苏谷壳 发表于 2017-8-18 17:07:26
  1. par(mfrow=c(2,2))

  2. #1
  3. bland_altman_plot <- function(the_1st_peak1,the_1st_peak2,xlab="Average testresult", ylab="Deviation of experimental test")
  4. {
  5.   d1 <- ((the_1st_peak1 + the_1st_peak2)/2)
  6.   diff1 <- the_1st_peak1 - the_1st_peak2     
  7.   plot(diff1~d1,pch=16,ylim=c(-20,160),xlab=xlab,ylab=ylab,col=cols_L)
  8.   abline(h=mean(diff1)-c(-1.96,1.96)*sd(diff1),lty=2)
  9.   abline(h=mean(diff1))
  10. }
  11. bland_altman_plot(the_1st_peak1,the_1st_peak2,xlab="Mean of the_1st_peak1 and the_1st_peak2",ylab="Difference the_1st_peak1 and the_1st_peak2")

  12. #2
  13. bland_altman_plot <- function(PVIF1,PVIF2,xlab="Average testresult", ylab="Deviation of experimental test")
  14. {
  15.   d2 <- ((PVIF1 + PVIF2)/2)
  16.   diff2 <- PVIF1 - PVIF2     
  17.   plot(diff2~d2,pch=16,ylim=c(-10,100),xlab=xlab,ylab=ylab,col=cols_L)
  18.   abline(h=mean(diff2)-c(-1.96,1.96)*sd(diff2),lty=2)
  19.   abline(h=mean(diff2))
  20.   legend(x=60,y=100,c("1","2","3","4"),col=cols,pch=c(16),bty="n",ncol=1,cex=0.9,pt.cex=0.9,xpd=FALSE,text.width=2,x.intersp=0.6)
  21. }
  22. bland_altman_plot(PVIF1,PVIF2,xlab="Mean of PVIF1 and PVIF2",ylab="Difference PVIF1 and PVIF2")

  23. #3
  24. bland_altman_plot <- function(the_1st_peak1,PVIF1,xlab="Average testresult", ylab="Deviation of experimental test")
  25. {
  26.   d3 <- ((the_1st_peak1 + PVIF1)/2)
  27.   diff3 <- the_1st_peak1 - PVIF1     
  28.   plot(diff3~d3,pch=16,ylim=c(-100,140),xlab=xlab,ylab=ylab,col=cols_L)
  29.   abline(h=mean(diff3)-c(-1.96,1.96)*sd(diff3),lty=2)
  30.   abline(h=mean(diff3))
  31. }
  32. bland_altman_plot(the_1st_peak1,PVIF1,xlab="Mean of the_1st_peak1 and PVIF1",ylab="Difference the_1st_peak1 and PVIF1")

  33. #4
  34. bland_altman_plot <- function(the_1st_peak2,PVIF2,xlab="Average testresult", ylab="Deviation of experimental test")
  35. {
  36.   d4 <- ((the_1st_peak2 + PVIF2)/2)
  37.   diff4 <- the_1st_peak2 - PVIF2     
  38.   plot(diff4~d4,pch=16,ylim=c(-8,5),xlab=xlab,ylab=ylab,col=cols_L)
  39.   abline(h=mean(diff4)-c(-1.96,1.96)*sd(diff4),lty=2)
  40.   abline(h=mean(diff4))
  41. }
  42. bland_altman_plot(the_1st_peak2,PVIF2,xlab="Mean of the_1st_peak2 and PVIF2",ylab="Difference the_1st_peak2 and PVIF2")
复制代码

板凳
苏谷壳 发表于 2017-8-18 17:09:25
deem 发表于 2017-8-18 16:58
我现在的图例在第二个图上

报纸
deem 学生认证  发表于 2017-8-18 17:49:27
苏谷壳 发表于 2017-8-18 17:09
我现在的图例在第二个图上
我弄错啦。。。

地板
deem 学生认证  发表于 2017-8-18 17:54:28
画一个3*2的图,中间一行占位
  1. layout(mat = matrix(c(1,2,3,3,4,5), nrow = 3, byrow = TRUE),
  2.        heights = c(0.4,0.2,0.4))

  3. x <- seq(-4, 4, 0.01)
  4. plot(x, sin(x), "l")
  5. plot(x, cos(x), "l")
  6. plot(1, type = "n", axes=FALSE, xlab="", ylab="")
  7. legend(x = "center", legend = c('legend1', 'legend2'),
  8.        xjust = 1, yjust = 0.5)
  9. plot(x, tan(x), "l")
  10. plot(x, abs(x), "l")
复制代码

7
苏谷壳 发表于 2017-8-18 17:58:41
deem 发表于 2017-8-18 17:54
画一个3*2的图,中间一行占位
谢谢我试试

8
苏谷壳 发表于 2017-8-18 19:23:02
deem 发表于 2017-8-18 17:54
画一个3*2的图,中间一行占位
都弄好了,就是下边两个图和上边的图例距离较远,怎样样才能使上边的图和下边的图距离图例一样呢?谢谢啦

9
jinshunwu 发表于 2017-8-18 19:53:40
R作图也很漂亮。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-9 15:11