dplot {mrf2d}R Documentation

Plotting functions for lattice data

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

dplot(Z, legend = FALSE)

cplot(Y, legend = TRUE)

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

# 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")



[Package mrf2d version 1.0 Index]