【问题标题】:Define text size in R relative to plot window相对于绘图窗口定义 R 中的文本大小
【发布时间】:2022-11-19 03:48:19
【问题描述】:

当我用 RI 绘图时,我发现如果我最大化绘图窗口,文本会在我的绘图上重新调整。 Y问题是: 我可以用 text() 做什么来使字体大小相对于绘图窗口大小固定?


quartz(7,7) #Use window(7,7) for other windows and Linux
plot( 0,  xlim = c(0,10), ylim = c(0,10), ylab = '', xlab = '')
text(5,5, 'This is an example for Stackexchange. \n
            How can i chose a font size that is relative to the window\'s size?')

quartz(12,12) #Use window(12,12) for other windows and Linux
plot( 0,  xlim = c(0,10), ylim = c(0,10), ylab = '', xlab = '')
text(5,5, 'This is an example for Stackexchange. \n
            How can i chose a font size that is relative to the window\'s size?')

图片显示了我的意思

我试过使用 cex 参数但它改变了字体大小的绝对值(不是相对的)

【问题讨论】:

    标签: r plot


    【解决方案1】:

    您已要求 7 英寸 x 7 英寸的绘图,并获得了相应的文本。然后你要求一个 12 英寸 x 12 英寸的绘图,但显然它不适合你的窗口,你得到了更小的东西,然后你再次调整它的大小给我们看。在这两种情况下,您都要求 12 点文本(默认)。

    如果您希望文本的大小与窗口成比例,那么您应该提出要求。例如,如果您对第一个图感到满意并希望第二个图的大小相同,请尝试

    quartz(12, 12, pointsize = 12*(12/7))
    

    其中 12*(12/7) 根据您要求的窗口大小与前一个窗口大小的比率重新缩放默认的 12 点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-14
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多