Help with axis and tick marks

1,263 views
Skip to first unread message

Kim Jung Hwa

unread,
Mar 30, 2010, 11:34:22 PM3/30/10
to ggplot2
Hi All,

I need some help with:

1. Changing colour=black for ticks marks on circle outline (currently
its white).
2. Removing numeric label "1" which is appearing on y-axis of
following pie chart.

# R Code
library(ggplot2)
pg <- ggplot(as.data.frame.table(VADeaths), aes(x = factor(1), y =
Freq, fill = Var1)) +
geom_bar(width = 1) +
facet_wrap(~Var2, scales = "free_y") +
coord_polar(theta = "y") +
opts(panel.grid.major = theme_blank())
print(pg)

Thanks in advance,
Kim

Dennis Murphy

unread,
Mar 31, 2010, 4:15:19 AM3/31/10
to Kim Jung Hwa, ggplot2
Hi:

I can help remove the labels on the y-axis and change the title on the legend,
but I don't know how to change the tick marks on the pie to black (and I'm not sure
you want to, because it will interfere with the numeric labels...but I digress).

I prefer to set the 'scaffolding' of the plot first and save it to an object:


pg <- ggplot(as.data.frame.table(VADeaths),
                  aes(x = factor(1), y = Freq, fill = Var1))

# Then,

pg + geom_bar(width = 1) +

      facet_wrap(~Var2, scales = "free_y") +
      coord_polar(theta = "y") +
      scale_fill_hue("Age group") +                            # change legend title
      opts(panel.grid.major = theme_blank(),
           axis.text.y = theme_blank(),                        # remove y axis label
           axis.ticks = theme_blank()) +                      # remove y axis tick marks
      xlab("") + ylab("")                                             # remove pointless axis titles

This still leaves you with the problem of getting the color you want on the circumference
tick marks, but hopefully someone else can edify you on that point.

HTH,
Dennis


--
You received this message because you are subscribed to the ggplot2 mailing list.
To post to this group, send email to ggp...@googlegroups.com
To unsubscribe from this group, send email to
ggplot2+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ggplot2

Charlotte Wickham

unread,
Mar 31, 2010, 9:16:24 AM3/31/10
to Dennis Murphy, Kim Jung Hwa, ggplot2
To get the ticks black:

last_plot() + opts(panel.grid.minor = theme_line(colour = "black")

But Dennis is right, it interferes with the labels.

Charlotte

> ggplot2+unsubscribegooglegroups.com or reply to this email with the words
> "REMOVE ME" as the subject.
>

Reply all
Reply to author
Forward
0 new messages