patternpie: Plot a pie chart using patterns and colors to fill the...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/patternpie.R

Description

The patternpie function is a tool for creating versatile pie charts by filling the slices with colors and patterns.

Usage

 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
)

Arguments

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.

Details

patternpie function offers flexible ways of doing pie charts.

Value

A ggplot object.

Author(s)

Chunqiao Luo (chunqiaoluo@gmail.com)

See Also

Function imagepie

Examples

 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))

Example output



patternplot documentation built on April 21, 2020, 5:05 p.m.