[R] A plot similar to violin plot
David Winsemius
dwinsemius at comcast.net
Wed Mar 9 04:58:54 CET 2011
On Mar 8, 2011, at 10:19 PM, David Winsemius wrote:
>
> On Mar 8, 2011, at 9:51 PM, Ista Zahn wrote:
>
>> I'm afraid I still don't get it (see in line below).
>>
>> On Wed, Mar 9, 2011 at 1:49 AM, C.H. <chainsawtiney at gmail.com> wrote:
>>> Sorry for being ambiguous.
>>>
>>> The data are some continuous variable (Y-axis) categorized into 3
>>> groups (Controls, Depressed EF and Preserved EF, X-asis).
>>
>> OK. I'm having trouble way before this though. Even taking just one
>> group, I still don't understand what this graphic is showing.
>>
>>>
>>> The band of dots on the plot is the data point.
>>
>> This is where I'm getting lost. You have a *band* of dots for each
>> data point (singular)? My head is exploding thinking about this. Why
>> do you have mutiple dots for each point?
>>
>> The density of dots
>>> and the "fatness" of the band present the frequency of a particular
>>> value in Y-axis.
>>
>> But the Y-axis variable is continuous. In order to have counts at
>> different values of y you will need to bin it somehow. And even then
>> you will still have only *one* value for the count in each bin. So
>> again, how and why are there muliple dots in each band (your term) /
>> bin (my term)?
>>
>> This property is similar to the violin plot: showing
>>> the probability density of the data at different values. Instead of
>>> showing a shape in violin plot, this plot shows the actual
>>> distribution of the data points.
>>
>> OK, so let's say we bin y and get the counts in each bin. We can plot
>> a point for each point that goes into that count, but what determines
>> the position of each point on the x-axis?
>>
>> It's entirely possible (even probable) that my poor little brain just
>> can't wrap itself around the idea. Maybe someone else can chime in
>> and
>> help me out.
>
> I was think that one might use jitter on the x coordinate (which is
> going to be a discrete value and if its a factor then:
>
> plot(jitter(as.numeric(...))
>
> It's not going to be in neat bands at each pseudo-continuous level.
> I have a fair amount of data that has values rounded to the nearest
> tenth, so my plots might look like the example graphic offered, if
> there were such a function.
>
> (I have avoid taking on this challenge so far because there was no
> example data.)
>
> y <- round(rnorm(300), digits=1)
> plot(jitter(rep(1,300), 5), y, xlim=c(0,2) )
>
> Or I suppose you could table() the y values, set up a blank plot
> with ylim set to range(y), and then "walk through" the entries with
> the points() function.
x <- round(rnorm(300), digits=1)
plot(NULL, type="n", xlim=c(0,2), ylim=range(x))
points( x= unlist(
sapply(table(x), function(z) seq(1.05-z/100, length=z,
by=0.02) )),
y= rep( as.numeric(names(table(x))), table(x)) ,
cex=0.8)
>
> --
> David.
>
>>
>> Best,
>> Ista
>>
>>>
>>> Thank you.
>>>
>>> Regards,
>>>
>>> CH
>>>
>>>
>>> On Tue, Mar 8, 2011 at 11:14 PM, Ista Zahn <izahn at psych.rochester.edu
>>> > wrote:
>>>> Hi,
>>>> I don't understand what is being plotted here. Can you describe
>>>> what
>>>> you want in more detail?
>>>>
>>>> Best,
>>>> Ista
>>>>
>>>> On Tue, Mar 8, 2011 at 7:27 AM, C.H. <chainsawtiney at gmail.com>
>>>> wrote:
>>>>> Dear R Users,
>>>>>
>>>>> I would like to know is there any package to create a plot like
>>>>> this?
>>>>>
>>>>> http://dl.dropbox.com/u/5409929/cs1160521f01.gif
>>>>>
>>>>> X axis is categorical. And the positions of the points are
>>>>> corresponding to the frequency. (similar to violinplot)
>>>>>
>>>>> Thank you.
>>>>>
>>>>> Regards,
>>>>>
>>>>> CH
>>>>>
>>>>> --
>>>>> CH Chan
>>>>>
>>>>> ______________________________________________
>>>>> 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.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Ista Zahn
>>>> Graduate student
>>>> University of Rochester
>>>> Department of Clinical and Social Psychology
>>>> http://yourpsyche.org
>>>>
>>>
>>>
>>>
>>> --
>>> CH Chan
>>>
>>
>>
>>
>> --
>> Ista Zahn
>> Graduate student
>> University of Rochester
>> Department of Clinical and Social Psychology
>> http://yourpsyche.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.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> ______________________________________________
> 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list