2

I have looked at this post but it is not quite what I want. Using superpose seems not to be working.

the plot function in R is really powerful. Applied to different objects, will give different results. When applied to the results of the fevd function (from extRemes package), it constructs a 2x2 set of plots (that can be slightly different depending on the model). here you can find an example.

After re-writing my own GEV fitting routines, I want to test my results against fevd's results. I want to plot my results on top of fevd's plots.

How do I extract the handles (does R has handles? objects?) of the plots and tell R, for example:

mimicking python

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

mimicking matlab

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

Thanks

Community
  • 1
  • 1
claude
  • 549
  • 8
  • 25

2 Answers2

2

You can use par()$mfg to check/set which plot on the current figure to use. For example,

## 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

Rorschach
  • 31,301
  • 5
  • 78
  • 129
  • Thanks! it did access the figure! but I think the fevd plots are manipulated in a way that I cannot plot over. Although the two plots look identical separately (same x/y range and visually identical) when I plot my new data, they are all squeezed in a corner. like if the two range of values were different, but they are not. I will try to post a figure. thanks. – claude Aug 26 '15 at 16:59
0

Not sure you can plot on same object. but to make this kind of plot, just use this syntax:

par(mfcol=c(2,2)) # divide the plotting space into 4 plots
plot(...) # first plot
plot(...) # second plot
plot(...) # third plot
plot(...) # fourth plot
HubertL
  • 19,246
  • 3
  • 32
  • 51
  • thanks - I knew that. But I really want to learn how to interact with plots obtained from plot(object...) where object could be the results of a variety of R packages. – claude Aug 25 '15 at 20:26