Automatically Prevent Legend from getting Cropped in R

I am working with the R programming language. I generated the following data:

 credibility_scoree = rnorm(100, 1, 0.3)
 average_recorded_height_in_study = rnorm(100, 17,3)
my_data = data.frame(credibility_scoree, average_recorded_height_in_study )
 my_data$credibility_score = ifelse(my_data$credibility_scoree>1,1,my_data$credibility_scoree)
my_data$credibility_score = my_data$credibility_score  * my_data$credibility_score 
my_data$credibility_scoree = NULL
my_data$study_number <- seq_along(my_data[,1])
my_data$adjusted_weight <- my_data$credibility_score * my_data$average_recorded_height_in_study

I then tried to make plots using the following library:

library(fitdistrplus)

 fg <- fitdist(my_data$adjusted_weight, "gamma")
 fln <- fitdist(my_data$adjusted_weight, "lnorm")
fg <- fitdist(my_data$adjusted_weight, "gamma")
 fw <- fitdist(my_data$adjusted_weight, "weibull")

 par(mfrow = c(2, 2))
 plot.legend <- c("Weibull", "lognormal", "gamma")

 denscomp(list(fw, fln, fg), legendtext = plot.legend)
qqcomp(list(fw, fln, fg), legendtext = plot.legend)
 cdfcomp(list(fw, fln, fg), legendtext = plot.legend)
 ppcomp(list(fw, fln, fg), legendtext = plot.legend)

enter image description here

As seen in these pictures, the legends are hidden by the graphs.

Question: Is there an automatic way to stop this from happening?

Thanks

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.