Package ‘patternplot’
December 20, 2016
Type Package
Title Versatile Pie Chart using Patterns, Colors, and Images
Version 0.1
Maintainer Chunqiao Luo <cluo@uams.edu>
Imports Rcpp (>= 0.11.0), ggplot2 (>= 2.1.0), jpeg (>= 0.1-8), png (>=
0.1-7), grDevices, utils, RcppParallel, dplyr, gtable
Depends R (>= 3.0.2)
Suggests knitr, Cairo, RCurl, rmarkdown
VignetteBuilder knitr
Date 2016-12-2
License GPL
Description Creates aesthetically pleasing and informative pie charts.
It can plot pie charts either in black and white or in colors,
with or without filled patterns. On the one hand, black and white pie charts filled
with patterns are useful for publications, especially when an increasing
number of journals only accept black and white figures or charge a
significant amount for a color figure. On the other hand, colorful pie
charts with or without patterns are useful for print design, online publishing,
or poster and 'PowerPoint' presentations. 'patternplot' allows the flexibility of a
variety of combinations of patterns and colors to choose from. It also has the
ability to fill in the slices with any external images in 'png' and 'jpeg' formats.
In summary, 'patternplot' allows the users to be as creative as they can while
creating pie charts!
LinkingTo Rcpp, RcppParallel
SystemRequirements GNU make
RoxygenNote 5.0.1
NeedsCompilation yes
Author Chunqiao Luo [aut, cre],
Shasha Bai [aut]
Repository CRAN
Date/Publication 2016-12-20 15:43:04
1
2
imagepie
R topics documented:
imagepie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
patternpie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Index
imagepie
2
3
6
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. It can create either black and white pie charts which are useful for scientific
publications, or colorful pie charts which are good for presentations.
Usage
imagepie(group, pct, label, label.size = 4, label.color = "black",
label.distance = 1.35, pattern.type, frame.color = "black",
frame.size = 1)
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.
Details
imagepie function offers flexible ways in doing pie charts.
Value
A ggplot object.
Author(s)
Chunqiao Luo (cluo@uams.edu)
patternpie
3
See Also
Function patternpie
Examples
library(patternplot)
#Fill slices with png images.
library(png)
Lines <- readPNG(system.file("img", "lines.png", package="patternplot"))
Chessboard <- readPNG(system.file("img", "chessboard.png", package="patternplot"))
Dots <- readPNG(system.file("img", "dots.png", package="patternplot"))
pattern.type<-list(Chessboard, Lines,Dots)
group<-c('chessboard','Lines', 'Dots')
pct<-c(25, 40, 35)
label<-c("Chessboard 25\% ", "Lines 40\%", "Dots 35\%")
p<-imagepie(group=group,pct=pct,label=label,pattern.type=pattern.type,label.distance=1.26,
frame.color='black')
p
#Fill slices with jpeg images.
library(jpeg)
Tomatoes <- readJPEG(system.file("img", "tomatoes.jpg", package="patternplot"))
Peas <- readJPEG(system.file("img", "peas.jpg", package="patternplot"))
Peppers <- readJPEG(system.file("img", "peppers.jpg", package="patternplot"))
pattern.type<-list(Tomatoes,Peas,Peppers)
group<-c('Tomatoes', 'Peas', 'Peppers')
pct<-c(40, 25, 35)
label<-c("Tomatoes \n 40\%", "Peas \n 25\% ", "Peppers \n 35\%")
p<-imagepie(group=group,pct=pct,label=label,pattern.type=pattern.type,label.distance=1.25,
frame.color='burlywood4', frame.size=0.8, label.size=6, label.color='forestgreen')
p
patternpie
Plot a piechart using patterns and colors to fill the slices.
Description
The patternpie function is a tool for creating versatile pie charts. It has the capacity to fill slices
with patterns and colors. Users can create either black and white pattern pie charts which are
useful for scientific publications, or colorful pie charts with or without patterns which are good for
presentations.
4
patternpie
Usage
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 = 1, background.color = rep("white",
length(group)), frame.color = "black", frame.size = 1, pixel)
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. There are 13 pattern types: ’blank’,
’bricks’, ’circles1’,’circles2’, ’crosshatch’,’dots’, ’grid’,’hlines’,’nelines’, ’nwlines’,
’shells’, ’vlines’, ’waves’.
pattern.color
a vector of colors for the lines/dots of patterns.
pattern.line.size
a numeric value, 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.
pixel
a numeric value, the pixel resolution of pie chart.
Details
patternpie function offers flexible ways in doing pie charts.
Value
A ggplot object.
Author(s)
Chunqiao Luo (cluo@uams.edu)
See Also
Function imagepie
patternpie
Examples
##Piecharts in black and white
#A simple example to start with.
library(patternplot)
group<-c('A', 'B')
pct<-c(25, 75)
label<-paste(group, ' ',pct,'%', sep='' )
pattern.type<-c('hlines', 'grid')
patternpie(group=group,pct=pct,label =label, pattern.type=pattern.type,
pixel=0.5, pattern.line.size=0.3, frame.size=1.5)
5
Index
imagepie, 2
patternpie, 3
6