小编sea*_*pen的帖子

R,图,字体大小在多个图中有所变化

我正在为出版物创建图表,并希望它们具有相同的字体大小.

当我创建一个包含多个图的图形时,即使我没有更改分辨率或参数,字体也会减小.我根据最终拟合图的数量增加了数字大小,并确保单个和多个绘图数字的边距相等.tiff()pointsize

以下是一个示例代码(字体大小在1x1和2x1数字之间是一致的,但是对于3x2数字减少):

tiff("1x1.tif", width=3,height=2.5,units="in",res=600,pointsize=8,
compression="lzw",restoreConsole=T)
par(mfrow=c(1,1),mar=c(4,4,.5,.5)+0.1)
plot(x=rnorm(10),y=rnorm(10))
dev.off()

tiff("2x1.tif", height=2.5*2,width=3,units="in",res=600,pointsize=8,
compression="lzw",restoreConsole=T)
par(mfrow=c(2,1),mar=c(2,4,2.5,0.5)+0.1)
plot(x=rnorm(10),y=rnorm(10),xaxt="n",xlab="")
par(mar=c(4,4,0.5,0.5)+0.1)
plot(x=rnorm(10),y=rnorm(10))
dev.off()

tiff("3x2.tif", height=2.5*3,width=3*2,units="in",res=600,pointsize=8,
compression="lzw",restoreConsole=T)
par(mfrow=c(3,2),mar=c(.5,4,4,0.5)+0.1)
plot(x=rnorm(10),y=rnorm(10),xaxt="n",xlab="")
par(mar=c(.5,2,4,2.5)+0.1)
plot(x=rnorm(10),y=rnorm(10),xaxt="n",xlab="",yaxt="n",ylab="")
par(mar=c(2.5,4,2,0.5)+0.1)
plot(x=rnorm(10),y=rnorm(10),xaxt="n",xlab="")
par(mar=c(2.5,2,2,2.5)+0.1)
plot(x=rnorm(10),y=rnorm(10),xaxt="n",xlab="",yaxt="n",ylab="")
par(mar=c(4.5,4,0,0.5)+0.1)
plot(x=rnorm(10),y=rnorm(10))
par(mar=c(4.5,2,0,2.5)+0.1)
plot(x=rnorm(10),y=rnorm(10),yaxt="n",ylab="")
dev.off()
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

PS:我没有使用ggplot2lattice因为我在"实际"数字上使用我自己的错误栏功能(我现在不记得为什么但是我尝试使用ggplot2错误栏并且没有得到我想要的).

plot r resolution font-size

2
推荐指数
1
解决办法
5944
查看次数

R,使用read.csv一步读入字符作为数字?

我正在将.csv读入带有几种不同变量类型的R中,其中两种作为字符读入,尽管它们是数字的(十进制度数的纬度和经度).为了解决这个问题,我在阅读之后将它们定义为"as.numeric".有更优雅的方法吗?也许在"read.csv"的调用中?

d <- read.csv("data.csv",stringsAsFactors=F)
> str(d)
'data.frame':   467674 obs. of  7 variables:
 $ station     : chr  "USC00036506" "USC00036506" "USC00036506" "USC00036506" ...
 $ station_name: chr  "SEARCY AR US" "SEARCY AR US" "SEARCY AR US" "SEARCY AR US" ...
 $ lat         : chr  "35.25" "35.25" "35.25" "35.25" ...
 $ lon         : chr  "-91.75" "-91.75" "-91.75" "-91.75" ...
 $ tmax        : int  50 50 39 100 72 61 -17 -44 6 0 ...
 $ tmin        : int  -39 -39 -89 -61 -6 -83 …
Run Code Online (Sandbox Code Playgroud)

import r read.table

0
推荐指数
1
解决办法
3万
查看次数

标签 统计

r ×2

font-size ×1

import ×1

plot ×1

read.table ×1

resolution ×1