尽管使用常规字体,但绘制的文本仍显示为粗体

时间:2018-04-05 10:26:55

标签: r data-visualization

我试图建立一个有点复杂的情节,我遇到了一个奇怪的错误。图表右侧的文字显示为粗体(呃),左侧是正常的,尽管我对两侧使用相同的规格。我尝试在两台不同的计算机上运行代码 - >相同的结果。

请参阅此处的代码以获取子图:

len=1 # length of feather section to plot
height <- 1-0.04 # height of feather section to plot
x0 <- 0 # VERTIVAL LINE POSITIOM  -  RACHIS
x1j <- 1; x1b <- -1 # right and left limit to barb lengths
plot(c(-len,len), c(-len,len), type='n',xlab='', ylab='', axes=F,
  xlim=c(-len/2,len/2), ylim=c(0.04,height))
  abline(v=x0, lwd=2)
abline(h=1)
abline(h=0)
a0 <- 0.03595088; a <- 0:60*a0
b <- tan( (90-35.86629)*pi/180)
for(j in 1:60){
    ax <- a[j] # intercept
    y0 <- b*x0 + ax
    y1 <- b*x1j + ax
    segments(x0,y0=y0, x1 =x1j, y1=y1)
    b1 <- round(35.86629, 0)
    b2 <- round(27.81573,0)
    text(x=len/3, y=len/15, substitute(paste(b1, degree)), cex=2, font=3)
    text(x=len/3, y=len/5.45,  substitute(paste(b2, "/cm")), col='seagreen', cex=2, font=3)
}
a0 <- 1/19.96685; a <- 0:60*a0
b <- tan( (90-26.49382)*pi/180)
for(j in 1:80){
    ax <- a[j] # intercept
    y0 <- b*x0 + ax
    y1 <- -b*(x1b) + ax
    segments(x0,y0=y0, x1 =x1b, y1=y1)
}
b1 <- round(26.49382, 0)
b2 <- round(19.96685,0)
text(x=-len/3, y=len/15, substitute(paste(b1, degree)), cex=2, font=3)
text(x=-len/3, y=len/5.45, substitute(paste(b2, "/cm")), col='seagreen',
     cex=2, font=3)
box()

知道为什么会这样,以及如何解决它?

enter image description here

1 个答案:

答案 0 :(得分:2)

右侧的文字在屏幕上显得更大胆,因为您实际上在for循环内打印了60次;你应该在循环外移动两个text()个调用。