Re: [R] plotting a dataset with median 0

From: Marc Schwartz <marc_schwartz_at_me.com>
Date: Sat, 05 Jun 2010 11:14:46 -0500

On Jun 5, 2010, at 9:08 AM, Georg Ehret wrote:

> Thank you, this is partially hepful Jim,
> my data are in 3 categories on the x-axis. Does anyone know of a method of
> plotting values identical on the y-axis distributed (adjacent to each other
> - piled up) on the x-axis?
> 
> 
> On Sat, Jun 5, 2010 at 12:00 PM, Jim Lemon <jim_at_bitwrit.com.au> wrote:
> 
>> On 06/05/2010 07:35 AM, Georg Ehret wrote:
>> 

>>> Dear R community,
>>> I am working on a dataset that has median 0 (due to many "0"
>>> entries)
>>> for my principal variable of interest (40 entries in total). I would like
>>> to
>>> plot a graph of this variable to show it visually, but have a hard time:
>>> boxplots are not informative (because median 0). Conventional scatterplots
>>> are neither. Is there a good way to do this (e.g. plotting the "0" values
>>> with a jitter or something else...)?
>>>
>>> Hi Georg,
>> Depending upon what you are plotting it against, count.overplot in the
>> plotrix package might do some good.
>> 
>> Jim


Georg,

Strictly speaking, a barplot() with 'beside = TRUE' might be helpful, but the offsetting nature of the bars can actually impede the interpretation the plot.

A barchart() in lattice would enable you to create separate barplots, one for each category per 'panel'. This can also be done using par("mfrow" = c(3, 1)) in base graphics, where you would end up with three barplot()s, vertically aligned over each other. You would just have to be sure to explicitly define the x and y axis axis limits appropriately, so that these are consistent across the three plots, to aid in the visual comparison. See ?par for more information.

Both of the above, presume that you are looking at discrete counts on the y axis and not a continuous distribution.

The histogram() function in lattice might be another approach, possibly with overlapping density plots, creating a histogram per group in each panel.

Overlapping density plots might make also sense. densityplot() in the lattice package would be one approach, as well as the sm.density.compare() function in the 'sm' CRAN package. An example of the latter is at the bottom of:

  http://www.statmethods.net/graphs/density.html

Examples of the lattice plots are at:

  http://bm2.genes.nig.ac.jp/RGM2/R_current/library/lattice/man/histogram.html

If you change the last densityplot() example to:

  library(lattice)
  densityplot( ~ height, groups = voice.part, data = singer, plot.points = FALSE)

you can get something similar to the overlapping density plots in the 'sm' package.

Food for thought.

HTH, Marc Schwartz



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. Received on Sat 05 Jun 2010 - 16:26:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 05 Jun 2010 - 17:00:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive