# [R] simple graphing question

David M Smith david at revolution-computing.com
Mon Feb 23 21:51:14 CET 2009

```If I understand your example correctly, I think you're looking for a
dot-chart like this one from the R Graph Gallery:

You'd just need to replace the green/blue circles with X's and O's,
respectively. Provided you reorganize your data the standard dotchart
function should do what you need.  See the code for the chart in the
graph gallery (or here: http://tinyurl.com/dby3jd ).

# David Smith

--
David M Smith <david at revolution-computing.com>
Director of Community, REvolution Computing www.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (Seattle, USA)

On Mon, Feb 23, 2009 at 12:38 PM, William Deese <williamdeese at gmail.com> wrote:
>
> I have what should be a simple question but I've been unable to solve
> it in a reasonable length of time. For example with data like
> > ge
>  product response scenario
> 1    wine        5     base
> 2   steel       10     base
> 3   sugar        4     base
> 4    wine      -10   policy
> 5   steel        1   policy
> 6   sugar      -20   policy
>
> (In reality there would be similar groups of data of various sizes). I
> would like to make dotplots with product on the left axis, x's for
> policy and o's for base scenario, say in red and blue. I would like to
> have horizontal lines from the product names across thru the x's and
> o's to the other side. Because positive or negative responses are
> important, I would like to have a vertical red line top to bottom at
> 0. I've experimented with dot.line, add.line to put in horizontal
> lines but was unsuccessful. Although the following code puts a red
> vertical line in, it is at the plot's left border.
>
> gedot <-
> function()
> {
> trellis.par.set(list(fontsize=list(text=12),
> dot.symbol=list(pch=c(1,4), col=c("blue","red")) ))
> print(dotplot(product ~ response, groups = scenario, pch=c(1,4),
> xlab="", ylab=NULL))
> panel.abline(v=0, col="red", reference=FALSE)
> }
>