rhistogrampsych

How to change the title of histograms created with pairs.panel()?


I used this function of the psych library to see the correlations of 3 samples with each other. While I could change the main title, I could not change the names of the histograms on the diagonal of the 3x3 graph. These take the names of the samples by default. How can I change the names of the histograms I'm talking about?

I did some research about it on the internet or tried to ask chatgpt but I couldn't find any information. I couldn't find anything in the documentation either. Here is my code:

pairs.panels(PartC[, c("Energy_consumption", "Energy_production", "CO2_emission")], 
             main = "The Correlation Between Energy Production, Energy Consumption, and the Amount of CO2 Emission.")

Solution

  • You could change the colnames of your data to the names you want to show in the plot. I use the built-in dataset iris as an example like this:

    library(psych)  
    data(iris)
    d = iris[1:4]
    colnames(d) = c("A", "B", "C", "D")
    pairs.panels(d, bg=c("red","yellow","blue"),
                 main="Title")
    

    Created on 2023-05-03 with reprex v2.0.2