How to automate labeling of many plot labels with the par() function?

351 views Asked by At

I am using the par() function to create a 3 x 4 matrix of histograms. I successfully used the apply function to populate the matrix, but I am having trouble labeling all of the plots.

I have tried doing so using a for loop such as this:

par(mfrow = c(3,4))
features <- colnames(winequality.white)
for (name in features){
  truehist(winequality.white$name)
  mtext(name)
}

but it gives me the error: Error in stats::var(x) : 'x' is NULL.

I prefer using the par function because it saves me the trouble of creating 12 separate graphical elements, but is there a way to automate the labeling of the plots?

Here is the code that I used to create the plots, as well as the graphical result:

#import/load data
winequality.white <- read.csv("/Users/me/Documents/winequality-white.csv", sep = ";")
#load library
library("MASS",lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
#Examine Histograms of the Data
par(mfrow = c(3,4))
apply(winequality.white, 2 , truehist )

enter image description here

Lastly, here is the data, which you can load with

winequality.white <- read.table("https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv", sep=";", header=TRUE)
0

There are 0 answers