r - 如何向具有 4 个子图的 R 图添加值

标签 r plot

我看过这个post但这并不完全是我想要的。使用 superpose 似乎不起作用。

R中的绘图功能真的很强大。应用于不同的对象,会得到不同的结果。当应用于 fevd 函数(来自 extRemes 包)的结果时,它会构造一组 2x2 的图(根据模型的不同,可能会略有不同)。 here你可以找到一个例子。

重写我自己的 GEV 拟合例程后,我想根据 fevd 的结果测试我的结果。我想将我的结果绘制在 fevd 的图之上。

如何提取绘图的句柄(R 有句柄吗?对象?)并告诉 R,例如:

模仿Python

ax = plt.subplot(221)
ax.plot(myxdata, myydata, 'o')

模仿matlab

subplot(2,2,1)
hold on
plot(myxdata, myydata, 'o')

谢谢

最佳答案

您可以使用par()$mfg来检查/设置当前图形上要使用的绘图。例如,

## Make a 2x2 figure
par(mfrow = c(2,2))
for(i in 1:4) plot(1,1, ylim=c(0,10), xlim=c(0,10))

## Current plot in focus
par()$mfg
# [1] 2 2 2 2

## Go back and put some points on the second figure
par(mfg=c(1,2))  # c(row, col)
points(1:10, col=1:10)

enter image description here

关于r - 如何向具有 4 个子图的 R 图添加值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32211603/

相关文章:

r - 在 data.table 中添加行,但在某些列采用相同值时不添加行

r - 将 data.frame 对象转换为 Zoo 对象

python - 使用 matplotlib,如何打印 "actual size"?

python - iPython notebook - 在子图次要 y 轴上设置 ylim

Python:根据类的无效 RGBA 参数 0.0 色点

R ggplot2 在使用 facet_grid 时使用 ..count..

r - 通过 Revolution R 聚合 .xdf

r - 使用 dplyr 来标记和计算值之间的差距

实时异常检测

python - 在绘制新图之前,如何从 matplotlib 图中删除点?