ez.piechart: pie chart

View source: R/plot.R

ez.piechartR Documentation

pie chart

Description

pie chart

Usage

ez.piechart(
  df,
  cmd,
  start = 0,
  direction = 1,
  color = "color",
  colors = ez.palette("Zhu"),
  alpha = 1,
  n.size = 5.5,
  n.type = 3,
  n.angle = 0,
  ylab = "",
  xlab = "",
  zlab = NULL,
  legend.position = "top",
  legend.direction = "horizontal",
  legend.box = T,
  legend.size = c(0, 10),
  xangle = 0,
  vjust = NULL,
  hjust = NULL,
  theme.apa = TRUE
)

Arguments

df

data frame in long format (but be careful that standard error might be inaccurate depending on grouping in the long format)
if it is already summary data, use mutate(tidyr::uncount(counter), value = 1) to turn into long format

cmd

a single col name

start

offset of starting point from 12 o'clock in radians eg, pi/3

direction

1, clockwise; -1, anticlockwise

color

"bw" or "color" black/white or colorblind-friendly color

alpha

pie alpha value

n.size

set to 0 to hide count/percentage

n.type

1 = pct; 2 = n; 3 = pct (n); 4 = n (pct)

n.angle

0, 45, 90, 180, 270

ylab

y label

xlab

x label

zlab

z/a/fill/legend label, only applicable when there is z provided NULL

legend.position

legend position 'top', 'bottom', 'left', 'right', 'none', c(x,y,two-element numeric vector)
c(0,0) corresponds to the "bottom left" and c(1,1) corresponds to the "top right" position.
if no z/a (legend) provided, auto force to 'none'

legend.direction

horizontal or vertical

legend.box

box of legend, T or F

legend.size

c(0,10) the first number 0 controls the legend title, 0=hide; the second number controls legend.key.size, legend.text

xangle

angle of x text 0

vjust

vjust of x text NULL

hjust

hjust of x text NULL

Value

a ggplot object (+theme_apa() to get apa format plot), +scale_y_continuous(limits=c(-5,8),breaks=seq(-5,8,by=2),oob=scales::rescale_none)
see http://stackoverflow.com/a/31437048/2292993 for discussion


jerryzhujian9/zmisc documentation built on March 9, 2024, 12:49 a.m.