Description Usage Arguments Details Value Author(s) See Also Examples
The patternpie
function is a tool for creating versatile pie charts
by filling the slices with colors and patterns.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | patternpie(
group,
pct,
label,
label.size = 4,
label.color = "black",
label.distance = 1.2,
pattern.type,
pattern.color = rep("black", length(group)),
pattern.line.size = rep(5, length(group)),
background.color = rep("white", length(group)),
frame.color = "black",
frame.size = 1,
density = rep(10, length(group)),
pixel = 20
)
|
group |
a vector of strings, containing the names of each slice. |
pct |
a vector of non-negative numbers, containing percentages of each group. The numbers must sum up to 100. |
label |
a vector of strings, giving the names for the slices shown in the pie chart. |
label.size |
the font size of labels shown in the pie chart. |
label.color |
the color of labels shown in the pie chart. |
label.distance |
the distance of labels from the border of the pie chart. |
pattern.type |
a vector of patterns to be filled in the slices. The pattern types include: 'blank', 'bricks', 'vdashes', 'hdashes', 'crosshatch','dots', 'grid','hlines','nelines', 'nwlines', 'vlines', 'waves' and more. |
pattern.color |
a vector of colors for the lines/dots of patterns. |
pattern.line.size |
a vector of numeric values, the line size for the lines/dots of patterns. |
background.color |
a vector of colors to be filled in the slices. |
frame.color |
the color for the borders of slices. |
frame.size |
a numeric value, the line size for the borders of slices. |
density |
a numeric vector, the density for the lines/dots of patterns. |
pixel |
a numeric value, the pixel resolution of pie chart. |
patternpie
function offers flexible ways of doing pie charts.
A ggplot object.
Chunqiao Luo (chunqiaoluo@gmail.com)
Function imagepie
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #Example 1
library(patternplot)
library(png)
library(ggplot2)
data <- read.csv(system.file("extdata", "vegetables.csv", package="patternplot"))
pattern.type<-c('hdashes', 'vdashes', 'bricks')
patternpie(group=data$group,pct=data$pct,label=data$label, label.size=4,label.color='black',
label.distance=1.2,pattern.type=pattern.type,pattern.line.size=c(5, 5, 2),
frame.color='black',frame.size=1.5, pixel=12, density=c(12, 12, 10))
#Example 2
pattern.color<-c('red3','green3', 'white' )
background.color<-c('dodgerblue', 'lightpink', 'orange')
patternpie(group=data$group,pct=data$pct,label=data$label, pattern.type=pattern.type,
pattern.color=pattern.color,background.color=background.color, pattern.line.size=c(5, 5, 2),
frame.color='grey40',frame.size=1.5, pixel=12, density=c(12, 12, 10))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.