Issue:
I have a list of histograms
which I created using the function as.ggplot() from the ggplotify package
and I assembled them into a grid of plots with the function cowplot::plot_grid()
.
My axis values and labels have disappeared and I was wondering if anyone can help to solve this issue (see figure below).
If anyone can help, I would be really grateful.
Dummy Data
#Dummy data
#Create a cluster column with dummy data (clusters = 3)
f1 <- gl(n = 2, k=167.5); f1
#Produce a data frame for the dummy level data
f2<-as.data.frame(f1)
#Rename the column f2
colnames(f2)<-"Country"
#How many rows
nrow(f2)
#Rename the levels of the dependent variable 'Country' as classifiers
#prefer the inputs to be factors
levels(f2$Country) <- c("France", "Germany")
#Create random numbers
Duration<-runif(335, min=2.192504e-02, max=3.155762)
Low.Freq<-runif(335, min=6.592500e+02, max=20491.803000)
High.Freq<-runif(335, min=2.051000e+03, max=36388.450000)
Start.Freq<-runif(335, min=1.195110e+02, max=23306.000000)
End.Freq<-runif(335, min=3.750000e+02, max=65310.000000)
Peak.Freq<-runif(335, min=7.324220+02, max=35595.703000)
Delta.Freq<-runif(335, min=1.171875+03, max=30761.719000)
Center.Freq<-runif(335, min=2.190000e-02, max=3.155800)
#Bind the columns together
Bind<-cbind(f2, Duration, Low.Freq, High.Freq, Start.Freq, End.Freq, Peak.Freq, Delta.Freq, Center.Freq)
#Produce a dataframe
Whistle_Parameters<-as.data.frame(Bind)
Whistle_Parameters
Data Transformation
#load packages
library(MASS)
library(car)
library(dplyr)
#Log10
log_10<-as.data.frame(Whistle_Parameters)
log_10
#Produce the log10 transformed values
log_10[paste0(names(log_10)[5:12], "_log")] <- lapply(log_10[5:12], log10)
#Produce a dataframe with the log10 values
Bind_log10<-cbind(log_10[1:4], log_10[16:23], log_10[13:15])
Bind_log10
#Final log10 dataframe
log10<-as.data.frame(Bind_log10)
log10
#Log
log<-as.data.frame(Whistle_Parameters)
log
#Produce the log10 transformed values
log[paste0(names(log)[5:12], "_log")] <- lapply(log[5:12], log)
#Produce a dataframe with the log10 values
Bind_log<-cbind(log[1:4], log[16:23], log[13:15])
Bind_log
#Final log10 dataframe
log<-as.data.frame(Bind_log)
log
#Box Cox
#Create a dataframe format for the Yeo transform
Box<-as.data.frame(Whistle_Parameters)
Box
#Check the structure of the dataframe 'Box'
str(Box)
#Use the function powerTransform(), specifying family = "bcPower", to obtain an optimal Box Cox transformation
transform_Low.Freq.box=car::powerTransform(Box$Low.Freq, family= "bcPower")
transform_Low.Freq.box
transform_High.Freq.box=car::powerTransform(Box$High.Freq, family= "bcPower")
transform_High.Freq.box
transform_Start.Freq.box=car::powerTransform(Box$Start.Freq, family= "bcPower")
transform_Start.Freq.box
transform_End.Freq.box=car::powerTransform(Box$End.Freq, family= "bcPower")
transform_End.Freq.box
transform_Peak.Freq.box=car::powerTransform(Box$Peak.Freq, family= "bcPower")
transform_Peak.Freq.box
transform_Center.Freq.box=car::powerTransform(Box$Center.Freq, family= "bcPower")
transform_Center.Freq.box
transform_Delta.Freq.box=car::powerTransform(Box$Delta.Freq, family= "bcPower")
transform_Delta.Freq.box
transform_Delta.Time.box=car::powerTransform(Box$Delta.Time, family= "bcPower")
transform_Delta.Time.box
#Produce a dataframe object
Box_Cox_Transformation<-as.data.frame(stand_box)
Box_Cox_Transformation
Histograms
#Histograms for raw values
Delta_Time_hist<-as.ggplot(~hist(Whistle_Parameters$Delta.Time, cex.axis = 0.5, cex.lab = 0.6))
Start_Freq_hist<-as.ggplot(~hist(Whistle_Parameters$Start.Freq, cex.axis = 0.5, cex.lab = 0.6))
End_Freq_hist<-as.ggplot(~hist(Whistle_Parameters$End.Freq, cex.axis = 0.5, cex.lab = 0.6))
Low_Freq_hist<-as.ggplot(~hist(Whistle_Parameters$Low.Freq, cex.axis = 0.5, cex.lab = 0.6))
High_Freq_hist<-as.ggplot(~hist(Whistle_Parameters$High.Freq, cex.axis = 0.5, cex.lab = 0.6))
Peak_Freq_hist<-as.ggplot(~hist(Whistle_Parameters$Peak.Freq, cex.axis = 0.5, cex.lab = 0.6))
Delta_Freq_hist<-as.ggplot(~hist(Whistle_Parameters$Delta.Freq, cex.axis = 0.5, cex.lab = 0.6))
Center_Freq_hist<-as.ggplot(~hist(Whistle_Parameters$Center.Freq, cex.axis = 0.5, cex.lab = 0.6))
#Histograms for log10 data
Delta_Time_hist_10 <- as.ggplot(~hist(log10(Whistle_Parameters$Delta.Time), cex.axis = 0.5, cex.lab = 0.6))
Start_Freq_hist_10<- as.ggplot(~hist(log10(Whistle_Parameters$Start.Freq), cex.axis = 0.5, cex.lab = 0.6))
End_Freq_hist_10<- as.ggplot(~hist(log10(Whistle_Parameters$End.Freq), cex.axis = 0.5, cex.lab = 0.6))
Low_Freq_hist_10<- as.ggplot(~hist(log10(Whistle_Parameters$Low.Freq),cex.axis = 0.5, cex.lab = 0.6))
High_Freq_hist_10<- as.ggplot(~hist(log10(Whistle_Parameters$Low.Freq), cex.axis = 0.5, cex.lab = 0.6))
Peak_Freq_hist_10<- as.ggplot(~hist(log10(Whistle_Parameters$Peak.Freq), cex.axis = 0.5, cex.lab = 0.6))
Delta_Freq_hist_10<- as.ggplot(~hist(log10(Whistle_Parameters$Delta.Freq), cex.axis = 0.5, cex.lab = 0.6))
Center_Freq_hist_10<- as.ggplot(~hist(log10(Whistle_Parameters$Center.Freq), cex.axis = 0.5, cex.lab = 0.6))
#Histograms for log data
Delta_Time_hist_log <- as.ggplot(~hist(log(Whistle_Parameters$Delta.Time), cex.axis = 0.5, cex.lab = 0.6))
Start_Freq_hist_log<- as.ggplot(~hist(log(Whistle_Parameters$Start.Freq), cex.axis = 0.5, cex.lab = 0.6))
End_Freq_hist_log<- as.ggplot(~hist(log(Whistle_Parameters$End.Freq), cex.axis = 0.5, cex.lab = 0.6))
Low_Freq_hist_log<- as.ggplot(~hist(log(Whistle_Parameters$Low.Freq),cex.axis = 0.5, cex.lab = 0.6))
High_Freq_hist_log<- as.ggplot(~hist(log(Whistle_Parameters$Low.Freq), cex.axis = 0.5, cex.lab = 0.6))
Peak_Freq_hist_log<- as.ggplot(~hist(log(Whistle_Parameters$Peak.Freq), cex.axis = 0.5, cex.lab = 0.6))
Delta_Freq_hist_log<- as.ggplot(~hist(log(Whistle_Parameters$Delta.Freq), cex.axis = 0.5, cex.lab = 0.6))
Center_Freq_hist_log<- as.ggplot(~hist(log(Whistle_Parameters$Center.Freq), cex.axis = 0.5, cex.lab = 0.6))
#Histograms Box Cox
Delta_Time_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$Delta.Time, cex.axis = 0.5, cex.lab = 0.6))
Start_Freq_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$Start.Freq, cex.axis = 0.5, cex.lab = 0.6))
End_Freq_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$End.Freq, cex.axis = 0.5, cex.lab = 0.6))
Low_Freq_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$Low.Freq, cex.axis = 0.5, cex.lab = 0.6))
High_Freq_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$High.Freq, cex.axis = 0.5, cex.lab = 0.6))
Peak_Freq_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$Peak.Freq, cex.axis = 0.5, cex.lab = 0.6))
Delta_Freq_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$Delta.Freq, cex.axis = 0.5, cex.lab = 0.6))
Center_Freq_hist.Cox<-as.ggplot(~hist(Box_Cox_Transformation$Center.Freq, cex.axis = 0.5, cex.lab = 0.6))
R Code
#Open a new graphics window
dev.new()
#Plot the histograms for all transformations against the raw parameter histograms to visually check skewness
plot_grid(Delta_Time_hist, Start_Freq_hist, End_Freq_hist, Low_Freq_hist, High_Freq_hist, Peak_Freq_hist, Delta_Freq_hist, Center_Freq_hist,
Delta_Time_hist_10, Start_Freq_hist_10, End_Freq_hist_10, Low_Freq_hist_10, High_Freq_hist_10, Peak_Freq_hist_10,
Delta_Freq_hist_10, Center_Freq_hist_10,
Delta_Time_hist_log, Start_Freq_hist_log, End_Freq_hist_log, Low_Freq_hist_log, High_Freq_hist_log, Peak_Freq_hist_log,
Delta_Freq_hist_log, Center_Freq_hist_log,
Delta_Time_hist.Cox, Start_Freq_hist.Cox, End_Freq_hist.Cox, Low_Freq_hist.Cox, High_Freq_hist.Cox, Peak_Freq_hist.Cox,
Delta_Freq_hist.Cox, Center_Freq_hist.Cox,
labels=c("(1) Raw Delta.time", "(2) Raw Start.Freq", "(3) Raw End.Freq", "(4) Raw Low.Freq",
"(5) Raw High.Freq", "(6) Raw Peak.Freq", "(7) Raw Delta.Freq", "(8) Raw Centre.Freq",
"(9) Log10 Delta.time", "(10) Log10 Start.Freq", "(11) Log10 End.Freq", "(12) Log10 Low.Freq",
"(13) Log10 High.Freq", "(14) Log10 Peak.Freq", "(15) Log10 Delta.Freq",
"(16) Log10 Centre.Freq", "(17) Log Delta.time", "(18) Log Start.Freq", "(19) Log End.Freq",
"(20) Log Low.Freq", "(21) Log High.Freq", "(22) Log Peak.Freq", "(23) Log Delta.Freq",
"(24) Log Centre.Freq", "(25) Box-Cox Delta time", "(26) Box-Cox Start.Freq",
"(27) Box-Cox End.Freq", "(28) Box-Cox Low.Freq", "(29) Box-Cox High.Freq",
"(30) Box-Cox Peak.Freq", "(31) Box-Cox Delta.Freq", "(32) Box-Cox Centre.Freq"),
ncol=8, nrow=4,
align="hv",
label_fontface = "bold",
hjust = 0, label_x = 0.01,
label_size = 8,
axis = "tblr",
rel_widths = c(2, 2, 2, 2, 2, 2, 2, 2, 2),
rel_heights = 0.3)