Skip to content
Prev 10621 / 15380 Next

[R-es] Ayuda con gráfico típico de histograma más linea

Y bueno, algo más bonito sí que queda con ggplot...

#---------------
datIn <- read.csv("pec.csv", header = TRUE, sep = ";", dec = ",")

library(ggplot2)
lab_x_idx <- c(1, round(nrow(datIn)/2, 0), nrow(datIn))
lab_x <- as.vector(datIn$hora[ lab_x_idx])
fre_gg <- ggplot( datIn, aes( x = 1:nrow(datIn),   y = frec)) +
             geom_bar(stat = "identity") +
             xlab(paste("Rango horas: ", datIn$hora[1], "-",
datIn$hora[nrow(datIn)], sep = "") ) +
             ylab("Frecuencia") +
             scale_x_continuous( breaks = lab_x_idx, labels = lab_x ) +
             theme_minimal()
sha_gg <- ggplot( datIn , aes(x = 1:nrow(datIn), y = Share)) +
                 geom_line() +
                 xlab(paste("Rango horas: ", datIn$hora[1], "-",
datIn$hora[nrow(datIn)], sep = "") ) +
                 ylab("Share") +
                 ylim(0, max(datIn$Share)*1.10) +
                 scale_x_continuous( breaks = lab_x_idx, labels = lab_x ) +
                 theme_minimal()
library(gridExtra)
grid.arrange(fre_gg, sha_gg, nrow=2, ncol=1)

#---------------

Saludos,
Carlos Ortega
www.qualityexcellence.es



El 2 de septiembre de 2016, 21:47, Carlos Ortega <cof en qualityexcellence.es>
escribió: