jchitpin / R2pgf

A matlab2tikz inspired wrapper to convert ggplot2 objects into beautiful pgfplot graphs in LaTeX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Motivation

  • You like LaTeX
  • You like consistent looking text and figures
  • You use ggplot2 for plotting
  • You've tried tikzDevice but hate tinkering to make it look less 'R'-like
  • You want an automated method of generating pgfplot figures from ggplot2 objects

Notes

  • Depending on how complex your plots are, you may have to edit the .tex file for final tweaks
  • Please double check the pgfplots graphs with the ggplot2 one to make sure everything looks right

Updates

  • This is a heavy work in progress!
  • 30/05/2019 - First started on |scatter2pgf|
  • TBD: Marker sizes and linewidth are directly converted to 'pt' (too small)
  • TBD: Specifying legend aesthetic requires 'x' and 'y' column name for g
  • TBD: Specifying legend aesthetic makes x/y-labels 'x' and 'y'
  • TBD: Add support for separate fill/border colours
  • TBD: Title support

Workflow

  1. g <- ggplot(...)
  2. g <- ggplot_build(g)
  3. R2pgf::function(g, ...)

General features

  • User-defined plot width and height
  • Redesigned pgfplots marker table for ggplot2 shapes (fill and border colours are the same)

scatter2pgf

  • Plots all points separated by aesthetic
  • (Marker) size, alpha, fill, and stroke, are all handled automatically (converted to pt)
  • stat_smooth linear regression is implemented (no standard error bars yet)
  • geom_line for vertical lines is implemented (because vertical lines aren't handled by stat_smooth
  • Aesthetic legend groups are automatically generated (need to re-label x/y axis on the plots)

About

A matlab2tikz inspired wrapper to convert ggplot2 objects into beautiful pgfplot graphs in LaTeX.


Languages

Language:R 53.2%Language:TeX 46.8%