imagerings2: Plot a ring chart using images to fill the rings.

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

View source: R/imagerings2.R

Description

The imagerings2 function is a tool for creating versatile ring charts by filling the rings with images.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
imagerings2(
  group1,
  group2,
  pct1,
  pct2,
  label1,
  label2,
  label.size1 = 4,
  label.size2 = 4,
  label.color1 = "black",
  label.color2 = "black",
  label.distance1 = 1.2,
  label.distance2 = 1.2,
  pattern.type1,
  pattern.type2,
  pattern.type.inner,
  frame.color = "black",
  frame.size = 1,
  r1,
  r2,
  r3
)

Arguments

group1

a vector of strings, containing the names of each slice for the inner ring.

group2

a vector of strings, containing the names of each slice for the outer ring.

pct1

a vector of non-negative numbers, containing percentages of each group for the inner ring. The numbers must sum up to 100.

pct2

a vector of non-negative numbers, containing percentages of each group for the outer ring. The numbers must sum up to 100.

label1

a vector of strings, giving the names for the slices shown in the ring chart for the inner ring.

label2

a vector of strings, giving the names for the slices shown in the ring chart for the outer ring.

label.size1

the font size of labels shown in the ring chart for the inner ring.

label.size2

the font size of labels shown in the ring chart for the outer ring.

label.color1

the color of labels shown in the ring chart for the inner ring.

label.color2

the color of labels shown in the ring chart for the outer ring.

label.distance1

the distance of labels from the border of the ring chart for the inner ring.

label.distance2

the distance of labels from the border of the ring chart for the outer ring.

pattern.type1

a list of objects returned by readPNG and readJPEG used to fill the inner ring.

pattern.type2

a list of objects returned by readPNG and readJPEG used to fill the outer ring.

pattern.type.inner

an object returned by readPNG and readJPEG used to fill the inner circle.

frame.color

the color for the borders of rings.

frame.size

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

r1

a numeric value, the inner radius of the inner ring.

r2

a numeric value, the outer radius of the inner ring.

r3

a numeric value, the outer radius of the outer ring.

Details

imagerings2 function offers flexible ways of doing ring charts.

Value

A ggplot object.

Author(s)

Chunqiao Luo (chunqiaoluo@gmail.com)

See Also

Function patternrings2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#Example 1
library(patternplot)
library(png)
library(ggplot2)
group1<-c("Wind", "Hydro", "Solar", "Coal", "Natural Gas", "Oil")
pct1<-c(12, 15, 8, 22, 18, 25)
label1<-paste(group1, " \n ", pct1 , "%", sep="")
location<-gsub('\\','/',tempdir(), fixed=TRUE)
pattern(type="blank", density=1, color='white', pattern.line.size=1, 
background.color="darkolivegreen1",  pixel=18, res=12)
Wind<-readPNG(paste(location,'/',"blank",".png", sep=''))
pattern(type="blank", density=1, color='white', pattern.line.size=1, 
background.color="white", pixel=18, res=12)
Hydro<-readPNG(paste(location,'/',"blank",".png", sep=''))
pattern(type="blank", density=1, color='white', pattern.line.size=1, 
background.color="indianred",  pixel=18, res=12)
Solar<-readPNG(paste(location,'/',"blank",".png", sep=''))
pattern(type="blank", density=1, color='white', pattern.line.size=1, 
background.color="gray81",  pixel=18, res=12)
Coal<-readPNG(paste(location,'/',"blank",".png", sep=''))
pattern(type="blank", density=1, color='white', pattern.line.size=1, 
background.color="white",  pixel=18, res=12)
NaturalGas<-readPNG(paste(location,'/',"blank",".png", sep=''))
pattern(type="blank", density=1, color='white', pattern.line.size=1, 
background.color="sandybrown",  pixel=18, res=12)
Oil<-readPNG(paste(location,'/',"blank",".png", sep=''))
pattern.type1<-list(Wind, Hydro, Solar, Coal, NaturalGas, Oil)

group2<-c("Renewable", "Non-Renewable")
pct2<-c(35, 65)
label2<-paste(group2, " \n ", pct2 , "%", sep="")
pattern(type="grid", density=12, color='white', pattern.line.size=5, 
background.color="seagreen", pixel=18, res=12)
Renewable<-readPNG(paste(location,'/',"grid",".png", sep=''))
pattern(type="blank", density=1, color='white', pattern.line.size=1, 
background.color="deepskyblue",  pixel=18, res=12)
NonRenewable<-readPNG(paste(location,'/',"blank",".png", sep=''))


pattern.type2<-list(Renewable, NonRenewable)
pattern.type.inner<-readPNG(system.file("img", "earth.png", package="patternplot"))

g<-imagerings2(group1, group2,pct1,pct2, label1, label2, label.size1=3, label.size2=3.5, 
label.color1='black', label.color2='black', label.distance1=0.7, label.distance2=1.3, 
pattern.type1, pattern.type2, pattern.type.inner, frame.color='skyblue',frame.size=1, 
r1=2.2, r2=4.2, r3=5)
g<-g+scale_x_continuous(limits=c(-7, 7))+scale_y_continuous(limits=c(-7, 7))
g

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