Learn R Programming

patternplot (version 2.0.0)

imagepie: Plot a pie chart with slices filled with png and jpeg images.

Description

The imagepie function is a tool for creating versatile pie charts by filling the slices with external png and jpeg images.

Usage

imagepie(
  group,
  pct,
  label,
  label.size = 4,
  label.color = "black",
  label.distance = 1.35,
  pattern.type,
  frame.color = "black",
  frame.size = 1
)

Value

A ggplot object.

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 list of objects returned by readPNG and readJPEG used to fill slices.

frame.color

the color for the borders of slices.

frame.size

a numeric value, the line size for the borders of slices.

Author

Chunqiao Luo (chunqiaoluo@gmail.com)

Details

imagepie function offers flexible ways of doing pie charts.

See Also

Function patternpie

Examples

Run this code
library(patternplot)
library(jpeg)
library(ggplot2)
Tomatoes <-  readJPEG(system.file("img", "tomatoes.jpg", package="patternplot"))
Peas <- readJPEG(system.file("img", "peas.jpg", package="patternplot"))
Potatoes <-  readJPEG(system.file("img", "potatoes.jpg", package="patternplot"))

#Example 1
data <- read.csv(system.file("extdata", "vegetables.csv", package="patternplot"))
pattern.type<-list(Tomatoes,Peas,Potatoes)
imagepie(group=data$group,pct=data$pct,label=data$label,pattern.type=pattern.type,
         label.distance=1.25,frame.color='burlywood4', frame.size=0.8, label.size=6,
         label.color='forestgreen')


Run the code above in your browser using DataLab