ez.lineplot: line plot with ggplot

View source: R/plot.R

ez.lineplotR Documentation

line plot with ggplot

Description

line plot with ggplot

Usage

ez.lineplot(
  df,
  cmd,
  colors = ez.palette("Zhu"),
  line.size = 0.7,
  error.size = 0.7,
  error.gap = 0,
  error.width = 0.3,
  error.direction = "both",
  ylab = NULL,
  xlab = NULL,
  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

like "y|x, y|x z, y|x z a" where y (axis) is continous, x (axis) z/a (legend) are discrete, during plot x z a ->x z(za combined)

line.size

the thickness of line, only applicable when there is z provided

error.size

the thickness of error bar line

error.gap

the location of errorbar, should not be adjusted, 0 (parameter kept for reference)

error.width

the width of the bar of error

error.direction

'both', 'max', 'min'

ylab

y label NULL

xlab

x label NULL

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/ezmisc documentation built on March 9, 2024, 12:44 a.m.