[R] Hello R user!
Christopher W Ryan
cryan at binghamton.edu
Tue Dec 17 19:46:09 CET 2013
Here is a simple example (without the proportional size
bubbles--you've been given some references on that) using the lattice
package:
# one dataframe holds the data from both "sources" I call them.
# they would be data from your two separate dataframes,
# that you call graph1 and graph2
dd <- data.frame(x=rnorm(10), y=rnorm(10), source=sample(c("A","B"),
10, replace=TRUE))
dd
library(lattice)
xyplot(y~x | source, data=dd)
# or another way
xyplot(y~x, groups=source, data=dd, auto.key=TRUE)
You'll want to think about how you are storing your data. Certain ways
of doing it lend themselves to certain ways of graphing. Some ways
make things difficult . . .
--Chris Ryan
On Tue, Dec 17, 2013 at 1:24 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
> On Tue, Dec 17, 2013 at 1:04 PM, bibek sharma <mbhpathak at gmail.com> wrote:
>> Hi Sarah,
>> It is not about mfrow or mfcol. I would like to see both sets of data in
>> one figure.
>> All I want was combining these two plots to one.
>> Any suggestions?
>> Bibek
>
> Suggestions? Yes. Read the link I and others provided about
> reproducible questions.
>
> Then there's the suggestion I already provided, using points() or
> lines() to add more data, possibly with xlim or ylim specified (see
> ?par for details). Without a reproducible example, I can't give
> specific details.
>
>> Also, size of the circle in the plots represents rates and so should be
>> shown in different sizes.
>> I tried using plots and points but this did not give me different sizes.
>
> If you want to use base graphics, then cex is what you need (see, you
> guessed it, ?par). You can pass a vector of sizes for your plotting
> character.
>
> For more sophisticated approaches, you might google "bubble plot R" for ideas.
>
> Sarah
>
>>
>>
>> On Tue, Dec 17, 2013 at 9:45 AM, Sarah Goslee <sarah.goslee at gmail.com>
>> wrote:
>>>
>>> What do you mean by "merge these figures in one"? If you want two
>>> figures on one page, see ?par - specifically mfrow and mfcol.
>>>
>>> If you want both sets of data in one figure, maybe ?points or ?lines
>>> though I see you're already familiar with at least ?lines.
>>>
>>> The list doesn't take most attachments, and you might also take a look at:
>>>
>>> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
>>>
>>> Asking intelligible questions is the best strategy for receiving
>>> intelligible answers.
>>>
>>> Sarah
>>>
>>> On Tue, Dec 17, 2013 at 12:33 PM, bibek sharma <mbhpathak at gmail.com>
>>> wrote:
>>> > Hello R user,
>>> >
>>> > I have created two plots (attached!) using the codes below
>>> > and would like to merge these figures in one. any suggestions are highly
>>> > appreciated!
>>> > Thanks,
>>> >
>>> > plot(graph1$yod,graph1$xod,data=graph1)
>>> > dfx = data.frame(ev1=graph1$xod, ev2=graph1$yod, ev3=abs(graph1$dif))
>>> > symbols(x=dfx$ev1, y=dfx$ev2, circles=dfx$ev3,inches=1/8, ann=F,
>>> > bg="black", fg=NULL,xlim=c(-35,35),ylim=c(-35,35))
>>> > abline(h=0,v=0)
>>> >
>>> > plot(graph2$yod,graph2$xod,data=graph2)
>>> > dfx = data.frame(ev1=graph2$xod, ev2=graph2$yod, ev3=abs(graph2$dif))
>>> > lines(symbols(x=dfx$ev1, y=dfx$ev2, circles=dfx$ev3,inches=1/8, ann=F,
>>> > bg="blue", fg=NULL,xlim=c(-35,35),ylim=c(-35,35)))
>>> > abline(h=0,v=0)
>>> >
>>> > Best,
>>> > Bibek
>>>
>>>
>
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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