maketikz: Generate Latex tikz code for plotting a temporal DAG, PDAG or...

View source: R/maketikz.R

maketikzR Documentation

Generate Latex tikz code for plotting a temporal DAG, PDAG or PAG.

Description

Generate Latex tikz code for plotting a temporal DAG, PDAG or PAG.

Usage

maketikz(
  model,
  xjit = 2,
  yjit = 2,
  markperiods = TRUE,
  xpgap = 4,
  annotateEdges = NULL,
  addAxis = TRUE,
  varLabels = NULL,
  periodLabels = NULL,
  annotationLabels = NULL,
  clipboard = TRUE,
  rawout = FALSE,
  colorAnnotate = NULL,
  bendedges = FALSE
)

Arguments

model

tpdag, tskeleton, tpag, or tamat object to plot.

xjit

How much should nodes within a period be jittered horizontally.

yjit

Vertical distance between nodes within a period.

markperiods

If TRUE, gray boxes are drawn behind each period.

xpgap

Horizontal gap between different periods.

annotateEdges

If TRUE, add a text annotation to edges. If annotationlabels are supplied, these labels will be used. Otherwise, the value in the inputted adjacency matrix corresponding to the edge will be used. Cannot be used for tpag input objects (or ag amat types).

addAxis

If TRUE, a horizontal axis with period labels are added.

varLabels

Optional labels for nodes (variables). Should be given as a named list, where the name is the variable name, and the entry is the label, e.g. list(vname = "Label for vname").

periodLabels

Optional labels for periods. Should be given as a named list, where the name is the period name (as stored in the tamat), and the entry is the label, e.g. list(periodname = "Label for period").

annotationLabels

Optional labels for edge annotations. Only used if annotateEdges = TRUE. Should be given as a named list, where the name is the edge annotation (as stored in the tamat), and the entry is the label, e.g. list(h = "High").

clipboard

If TRUE, the tikz code is not printed, but instead copied to the clipboard, so it can easily be pasted into a Latex document.

rawout

If TRUE, the tikz code is only returned as a character vector.

colorAnnotate

Named list of colors to use to mark edge annotations instead of labels. This overrules annotateEdges and both are not available at the same time. The list should be given with annotations as names and colors as entries, e.g. list(h = "blue"). Cannot be used for tpag input objects (or ag amat types).

bendedges

If TRUE, all edges are bend 10 degrees to the right, thereby avoiding having edges exactly on top of each other.

Details

Note that it is necessary to read in relevant tikz libraries in the Latex preamble. The relevant lines of code are (depending a bit on parameter settings):
\usepackage{tikz}
\usetikzlibrary{arrows.meta,arrows,shapes,decorations,automata,backgrounds,petri}
\usepackage{pgfplots}

Value

Silently returns a character vector with lines of tikz code. The function furthermore has a side-effect. If clipboard = TRUE, the side-effect is that the tikz code is also copied to the clipboard. If clipboard = FALSE, the tikz code is instead printed in the console.

Examples


# Make tikz figure code from tpdag, print code to screen
data(tpcExample)
tpdag1 <- tpc(tpcExample, order = c("child", "youth", "oldage"), sparsity = 0.01,
              test = corTest)
maketikz(tpdag1, clipboard = FALSE)

# Make tikz figure code from tamat, copy code to clipboard
thisdag <- simDAG(5)
rownames(thisdag) <- colnames(thisdag) <- c("child_x", "child_y",
                                            "child_z", "adult_x", 
                                            "adult_y")
thistamat <- tamat(thisdag, order = c("child", "adult"))        
## Not run: 
maketikz(thistamat)            

## End(Not run)   
              

causalDisco documentation built on Jan. 20, 2026, 5:09 p.m.