## -----------------------------------------------------------------------------
#| include: false
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5,
                      dpi = 96, out.width = "100%")


## -----------------------------------------------------------------------------
#| include: false
library(paintr)


## -----------------------------------------------------------------------------
#| fig-alt: "A 3 by 3 matrix of assorted positive and negative values, such as 10, 200, -30 down
#|   the first column, drawn in base graphics with each cell labelled by its [row, column]
#|   subscript from [1, 1] to [3, 3]."
mat <- matrix(c(10, 200, -30, 40, 500, 30, 90, -55, 10), ncol = 3)
paint_matrix(mat, show_indices = "cell")


## -----------------------------------------------------------------------------
#| fig-alt: "The same 3 by 3 matrix with the same [row, column] labels under each cell, drawn
#|   through the ggplot2 backend; cells, accessors, and the two-tone digits match the base-graphics
#|   version exactly."
gpaint_matrix(mat, show_indices = "cell")


## -----------------------------------------------------------------------------
#| fig-height: 3.2
#| fig-alt: "A named numeric vector holding 1, 2, 3 drawn as a column of three cells in base
#|   graphics, each labelled with its character accessor [\"a\"], [\"b\"], and [\"c\"]."
paint_vector(c(a = 1, b = 2, c = 3))


## -----------------------------------------------------------------------------
p <- gpaint_vector(c(a = 1, b = 2, c = 3))
class(p)


## -----------------------------------------------------------------------------
#| fig-height: 3.2
#| fig-alt: "The same named vector of 1, 2, 3 with accessors [\"a\"], [\"b\"], and [\"c\"], drawn by
#|   printing the stored ggplot object p; printing the object is what renders the picture."
p


## -----------------------------------------------------------------------------
#| eval: false
# ggsave("vector.png", p, width = 7, height = 3, dpi = 96)


## -----------------------------------------------------------------------------
#| fig-alt: "The 3 by 3 matrix drawn through ggplot2 and given the title \"A relabelled matrix\" and
#|   a caption reading \"drawn by paintr, retitled by ggplot2\"; the title and caption are ordinary
#|   ggplot labels wrapped around paintr's cell drawing."
gpaint_matrix(mat) +
  ggplot2::labs(title = "A relabelled matrix",
                caption = "drawn by paintr, retitled by ggplot2")

