| dplot | R Documentation |
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.
dplot(Z, legend = FALSE) cplot(Y, legend = TRUE)
Z |
A |
legend |
|
Y |
A |
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().
a ggplot object.
Victor Freguglia
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.