英文:
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.
答案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)
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论