Trim off plots that are modified by subsequent lines to only show the "final" plot.
Arguments
- x
An evaluation object produced by
evaluate()
.
Examples
ev <- evaluate(c(
"plot(1:3)",
"text(1, 1, 'x')",
"text(1, 1, 'y')"
))
# All intermediate plots are captured
ev
#> <evaluation>
#> Source code:
#> plot(1:3)
#> Plot [8]:
#> <base> C_plot_new()
#> <base> palette2()
#> <base> C_plot_window()
#> <base> C_plotXY()
#> <base> C_axis()
#> <base> C_axis()
#> <base> C_box()
#> <base> C_title()
#> Source code:
#> text(1, 1, 'x')
#> Plot [9]:
#> <base> C_plot_new()
#> <base> palette2()
#> <base> C_plot_window()
#> <base> C_plotXY()
#> <base> C_axis()
#> <base> C_axis()
#> <base> C_box()
#> <base> C_title()
#> <base> C_text()
#> Source code:
#> text(1, 1, 'y')
#> Plot [10]:
#> <base> C_plot_new()
#> <base> palette2()
#> <base> C_plot_window()
#> <base> C_plotXY()
#> <base> C_axis()
#> <base> C_axis()
#> <base> C_box()
#> <base> C_title()
#> <base> C_text()
#> <base> C_text()
# Only the final plot is shown
trim_intermediate_plots(ev)
#> <evaluation>
#> Source code:
#> plot(1:3)
#> Source code:
#> text(1, 1, 'x')
#> Source code:
#> text(1, 1, 'y')
#> Plot [10]:
#> <base> C_plot_new()
#> <base> palette2()
#> <base> C_plot_window()
#> <base> C_plotXY()
#> <base> C_axis()
#> <base> C_axis()
#> <base> C_box()
#> <base> C_title()
#> <base> C_text()
#> <base> C_text()