Skip to contents

Parses the PostScript a plot command writes into a table of drawing operations: line segments, polygons, symbols and text, with the graphics state that applied to each.

Usage

tda_read_ps(file, which = NULL)

Arguments

file

a .ps file written by TDA, or a run whose directory contains one.

which

when file is a run, the name of the PostScript file.

Value

A list with ops, the drawing operations, and bbox, the bounding box TDA declared. Each operation carries the plot command that produced it, taken from the %# annotations TDA writes into the stream.

Examples

d <- data.frame(x = 1:5, y = c(2, 4, 5, 8, 9))
p <- tda_ps(d, xlim = c(0, 6), ylim = c(0, 10))
p <- tda_pl_axes(p)
p <- tda_pl_lines(p, "x", "y")
pdf(NULL)  # plot() runs the session and draws it; capture the run
p <- plot(p)
dev.off()
#> agg_record_1f9b678a7aa4 
#>                       2 
ps <- tda_read_ps(p$run, which = p$file)
ps$bbox
#> [1] 145 455 438 663
ps$ops[[3]]$op
#> [1] "lines"