问题
I'm generating a simple pie chart with use of the code below:
data(mtcars)
mtcars$fac_var <- as.factor(mtcars$cyl)
require(ggplot2); require(ggthemes)
# Chart
pie_test <- ggplot(mtcars, aes(x = factor(1), fill = fac_var)) +
geom_bar(width = 1) +
coord_polar(theta = "y") +
ggtitle("Title") +
theme_pander() +
scale_fill_tableau(name = "Something") +
theme(axis.title = element_blank())
The code produces the following chart:
I'm interested in introducing two minor modifications to the chart above:
- I would like to remove the figure 1 visible on the left (highlighted in red in the picture below).
- I would like to make the lines leading to to the figures more strongly pronounced (highlighted in black in the picture below).
Desired changes:
回答1:
1.) To get rid of the "1-" edit your theme to:
theme(axis.title = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y = element_blank())
2.) To change the lines edit your theme to:
theme(axis.title = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y=element_blank(),
panel.grid.major.y = element_line(size = 1, color="black", linetype = "solid"))
Not a perfect solution but an improvement. Pie charts are not the best for conveying data. You may want to consider a bar chart. If you want more help with ggplot2 pie charts check out this post.
来源:https://stackoverflow.com/questions/33549739/controlling-ticks-and-odd-text-in-a-pie-chart-generated-from-a-factor-variable-i