R语言作图的小方法--作图布…

来源:互联网 发布:动漫 印象最深 知乎 编辑:程序博客网 时间:2024/04/30 07:56
图很好
原文地址:R语言作图的小方法--作图布局与坐标轴的控制作者:ILoveLittree

ILoveLittree

1.关闭x或者y轴的labxaxt='n' or yaxt="n"

2.关闭整个plot的窗口:axes=F

3.调整lab的字体大小:cex.lab=lab.size

4.调整轴的字体大小cex.axis=axis.size

5.调整轴元素之间的距离:mgp=c(2.5,1,0)

mgp:坐标轴各部件的位置。第一个元素为坐标轴位置到坐标轴标签的距离,以文本行高为单位。第二个元素为坐标轴位置到坐标刻度标签的距离。第三个元素为坐标轴位置到实际画的坐标轴的距离,通常是0

6.axis(1,at=half.len,labels=’test’,tick=F) #tick 控制坐标轴上的小竖线是否显示

7: X,Y轴互换用horiz=TRUE

8: axis labels的方向 las=0  0,1,2,3    

0: always parallel to the axis [default], 
1: always horizontal, 
2: always perpendicular to the axis, 
3: always vertical.

 

以例子示范:

plot(1:10,1:10,xlab="x",ylab="y",main="ILoveLittree",cex.axis=0.8,cex.lab=2,mgp=c(3,2,1))

[转载]R语言作图的小方法--作图布局与坐标轴的控制


更新ing

png("filename.png",width=500,height=500)

par(oma=c(3,3,3,3),mar=c(5,10,5,5),mgp=c(3,2,1),bty="o",xaxt='n')

plot(1:10,1:10,xlab="x",ylab="y",main="ILoveLittree",cex.axis=0.8,cex.lab=2)

box("inner", lty="dotted", col="red")

box("outer", lty="solid", col="blue")

mtext("Made by ILoveLittree", side=1, cex.lab=1.3,line=1, cex=1.2,font.axis=2,outer=TRUE,adj=0)


dev.off()


[转载]R语言作图的小方法--作图布局与坐标轴的控制



结合前一次的博客:http://blog.sina.com.cn/s/blog_6babbcb801019njz.html

糗世界: http://pgfe.umassmed.edu/ou/archives/2395

R: http://research.stowers-institute.org/mcm/efg/R/Graphics/Basics/mar-oma/index.htm



原创粉丝点击