Base R:在使用xlim时,绘图超出绘图窗口。

huangapple go评论98阅读模式
英文:

Base R: Plotting beyond the plotting window despite using xlim

问题

这个问题最好由以下代码行来描述:

> plot(1:100, 1:100, xlim = c(0, 50))

它生成了以下内容,其中图形超出了窗口范围。我不认为我以前在R中曾经遇到过这种情况。

英文:

The question is best described by this line of code

> plot(1:100,1:100, xlim = c(0,50))

It generates the following, which has the graph going outside of the window. I don't believe I have ever experienced this before in R.

Base R:在使用xlim时,绘图超出绘图窗口。

答案1

得分: 4

expand(xpd)参数被设置为NA(通过plot函数或全局设置如par(xpd = NA)),图形元素将扩展到图形之外。将par(xpd = FALSE)设置为在绘图区域内绘图(在框内 - 默认设置);将xpd = TRUE设置为在图形区域内绘图(在边距内),而xpd = NA允许在整个图形设备上绘图。请参阅?par中的xpd部分。

您可以通过重新启动R或运行par(xpd = FALSE)来恢复默认设置。

英文:

When the expand (xpd) parameter is set to NA (by the plot function or via global setting like par(xpd = NA)), plot elements will extend beyond plot. Setting par(xpd = FALSE) restricts plotting to the plot region (inside the box - the default); setting (xpd = TRUE) restricts plotting to the figure region (within the margins) and xpd = NA allows plotting over the entire graphics device. See the xpd section of ?par.

You can return to the default setting by restarting R or running the line par(xpd = FALSE).

huangapple
  • 本文由 发表于 2023年6月26日 02:15:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76551817.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定