[R] A plot similar to violin plot

Joshua Wiley jwiley.psych at gmail.com
Wed Mar 9 04:18:49 CET 2011


Hi CH,

Its sounds like what you are trying to do is plot continuous Y values
at categorical X values and rather than simply overplotting, spread
out points that would overlap on the X axis.  I have been working on
implementing something like this in R based on an algorithm from
Leland Wilkinson.  However, it is not yet release ready and does not
handle multiple groups (though that is on my list down the line, but I
have other problems to sort out, not the least of which is my own lack
of knowledge).  The attached PDF shows an example of what I mean, it
is the "mpg" column from the "mtcars" dataset.  If you want, you can
get the source for my development code here:
http://joshuawiley.com/R.aspx

In any case, what about doing something like a jittered scatter plot +
violin plot for now?  the jittering will let you see the data points
and the violin plot will get you the distribution.  It should be
relatively straight forward to do in ggplot2 or lattice.

Cheers,

Josh

On Tue, Mar 8, 2011 at 6:51 PM, Ista Zahn <izahn at psych.rochester.edu> 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.
>
> 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stackeddotplot.pdf
Type: application/pdf
Size: 5123 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110308/b9ac6047/attachment.pdf>


More information about the R-help mailing list