[R] Problems combining two plots using par(mfrow=)
Boris Steipe
boris.steipe at utoronto.ca
Sat Apr 18 16:20:36 CEST 2015
I can reproduce your problem. It affects both sine-waves if the graph is plotted as the second plot, so it seems that plotting the graph affects all subsequent plots. It affects all plots in subsequent plots to the same window. The window needs to be closed to correct this. I would file a bug report.
Two quick workarounds: plot only the x-values contained in your xlim range, or plot the graph last.
Cheers,
B.
On Apr 18, 2015, at 8:55 AM, Charles Novaes de Santana <charles.santana at gmail.com> wrote:
> Dear all,
>
> I am trying to plot 4 different plots in the same figure using
> par(mfrow=...) and igraph::plot.igraph. The code below reproduces more or
> less what I am doing:
>
> library(igraph)
>
> g<-erdos.renyi.game(30,0.4)
> x<-1:100;
>
> par(mfrow=c(2,2))
>
> hist(degree(g),main="A");
> plot(x,sin(x),type="l",xlab="x",ylab="sin(x)",xlim=c(10,60),main="B")
> plot(g,main="C");box();
> plot(x,sin(x),type="l",xlab="x",ylab="sin(x)",xlim=c(10,60),main="D")
>
> My problem is that the curve plotted in "D" is shown out of the margins. As
> it is exactly the same plot as in "B" and in "B" there is no problem with
> margins I suppose this is somehow related to the plot of the graph in "C".
>
> I tried to use the function graphics::layout instead of par(mfrow) and the
> same problem persists.
>
> I am using R "3.0.2" and Igraph "0.7.1" installed in a machine with Ubuntu
> 14.04.
>
> I sent this message to Igraph mailing-list but so far nobody could help me.
> I wonder if this problem happens also with other combinations of
> "par(mfrow)" and other kinds of plots, so I am sending this message also to
> this broader mailing list.
>
> Does any of you have any clue about how to solve this?
>
> Thanks for your attention and for any help,
>
> Charles
>
> --
> Um axé! :)
>
> --
> Charles Novaes de Santana, PhD
> http://www.imedea.uib-csic.es/~charles
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list