I am trying to make some plots using Highchart package in R. My plots are a qqcomp() and ppcomp(), I'd like to replicate this using highchart. I am able to do this using ggplot2 but I think they would look much better in Highchart.
This is my code:
library(fitdistrplus)
library(highcharter)
library(ggplot2)
x <- c(164.26, 229.61, 25.07,17.82,111.71,15.33,9849.52,35.8,354.69,255.12,166.36,1371.07,362.58,4212.29,8424.57)
fit.lnorm <- fitdist(x,"lnorm",method="mle", start = NULL)
fit.gamma <- fitdist(x,"gamma", method = "mle", lower = c(0, 0))
qcomp <- qqcomp(list(fit.lnorm, fit.gamma),
xlegend = "bottomright",
xlab = "Cuantiles teóricos",
ylab = "Cuantiles empíricos",
fitlty = 1,
fitcol = c("red1","springgreen2"),
plotstyle = "ggplot",
addlegend = FALSE)
pcomp <- ppcomp(list(fit.lnorm, fit.gamma),
xlegend = "bottomright",
xlab = "Probabilidades teóricas",
ylab = "Probabilidades empíricas",
fitlty = 1,
fitcol = c("red1","springgreen2"),
plotstyle = "ggplot",
addlegend = FALSE)
qcomp <- qcomp + theme_minimal() + ggtitle("Q-Q Plot")
pcomp <- pcomp + theme_minimal() + ggtitle("P-P Plot")
You can extract pretty much all the information needed to recreate the plot from the ggplot object. In particular:
Data
Mapping
With the above we can construct a highchart plot like this: