plotmatrix: Make charts with matrices

Description Usage Arguments Details Examples

Description

Given a named matrix or a data frame, this function will return a ggplot object that represents a tile chart with the values of the matrix. The library gives the user the choice to change the color , title and subtitle and the legend position in the plot.

Usage

1
2
3
4
5
plotmatrix(matrix, title = "", subtitle = "", low_color = "#132B43",
  high_color = "#56B1F7", legend_position = "top", xlabel = "",
  ylabel = "", title_size = 8, subtitle_size = 7, height = 0.9,
  width = 0.9, color = "black", key_size = 1.5, colour = "black",
  text_include = FALSE)

Arguments

matrix

named data.frame or matrix

subtitle

subtitle of the Plot

low_color

is the color assigned to the lowest value

high_color

is the color assigned to the highest value

legend_position

position of legend

xlabel

x label for the chart

ylabel

ylabel for the chart

title_size

size of the title text

subtitle_size

size of the subtitle text

height

height of each cell

width

width of each cell

color

color of the cell borders

key_size

size of legend keys

colour

colour of the labels

text_include

if text labels should be include; by default it is FALSE

header

header of the Plot

Details

If a data frame is used, the column will be taken as the column of the matrix and the rows will be taken as the rows of the matrix and the function will plot accordingly.

A matrix input is also allowed.

Chart title and x-axis and y-axis labels are optional.

plotmatrix is inspired by hrbrmstr's waffle package (@hrbrmstr)

Examples

1
2
3
4
5
data_matrix  <- data.frame(a=c(1,0,0),b=c(0,1,0),c=c(0,0,1))
plotmatrix(data_matrix)

# Plotting matrix with high and low color
plotmatrix(data_matrix,low_color="#f6efb9",high_color="#d6efd9")

adhok/plotmatrix documentation built on May 28, 2019, 3:55 p.m.