dplot: Plotting functions for lattice data

Description Usage Arguments Details Value Author(s) Examples

View source: R/plot.R

Description

dplot() and cplot() are functions for plotting lattice data. They are an alternative to base R's image() function using ggplot2 instead. dplot is used for discrete data and cplot for continuous data, they only differ in the fact that pixel values are treated as a factor in dplot, therefore, a discrete scale is used.

Usage

1
2
3

Arguments

Z

A matrix object with integers only.

legend

logical indicating whether a legend should be included or not.

Y

A matrix object with continuous values.

Details

Since returns a ggplot object, other layers can be added to it using the usual ggplot2 syntax in order to modify any aspect of the plot.

The data frame used to create the object has columns named x, y and value, which are mapped to x, y and fill, respectively, used with geom_tile().

Value

a ggplot object.

Author(s)

Victor Freguglia

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Plotting discrete data
dplot(Z_potts)

#Making it continuous
cplot(Z_potts + rnorm(length(Z_potts)))

#Adding extra ggplot layers
library(ggplot2)
dplot(Z_potts) + ggtitle("This is a title")
dplot(Z_potts, legend = TRUE) + scale_fill_brewer(palette = "Set1")

mrf2d documentation built on Oct. 30, 2020, 1:07 a.m.