|
### Przykładowe dane x=c(3,6,4,8) barplot(x)
barplot(x,col=3)
barplot(x,col=1:4)
### Wykresy dla danych Orange barplot(Orange$circumference)
barplot(Orange$age,col=3)
barplot(Orange$age,col=rainbow(7))
barplot(Orange$age,col=rainbow(35))
barplot(sort(Orange$circumference))
### Wykrews słupkowy z biblioteki gplots
library(gplots) # Dodane 95% słupki błędów hh <- t(VADeaths)[, 5:1] mybarcol <- "gray20" ci.l <- hh * 0.85 ci.u <- hh * 1.15 mp <- barplot2(hh, beside = TRUE, col = c("lightblue", "mistyrose", "lightcyan", "lavender"), legend = colnames(VADeaths), ylim = c(0, 100), main = "Death Rates in Virginia", font.main = 4, sub = "Faked 95 percent error bars", col.sub = mybarcol, cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u, plot.grid = TRUE) mtext(side = 1, at = colMeans(mp), line = 2, text = paste("Mean", formatC(colMeans(hh))), col = "red") box()
Wykresy słupkowe z biblioteki UsingR
library(UsingR) record.high=c(95,95,93,96,98,96,97,96,95,97) record.low= c(49,47,48,51,49,48,52,51,49,52) normal.high=c(78,78,78,79,79,79,79,80,80,80) normal.low= c(62,62,62,63,63,63,64,64,64,64) actual.high=c(80,78,80,68,83,83,73,75,77,81) actual.low =c(62,65,66,58,69,63,59,58,59,60) x=rbind(record.low,record.high,normal.low,normal.high,actual.low,actual.high) the.names=c("S","M","T","W","T","F","S")[c(3:7,1:5)] superbarplot(x,names=the.names)
### Histogram attach(chickwts) hist(weight)
hist(weight,col=2)
hist(weight,col=1:7)
hist(weight,col=2,breaks=3)
hist(weight,col=2,breaks=18)
hist(weight,col=2,breaks=18,border="blue")
hist(rnorm(1000),col=3)
hist(rnorm(1000),col=3,density=15)
hist(rivers)
hist(rivers,n=20, col=rainbow(20))
hist(rivers,breaks=c(20,100,200,300,400,500,1000,4000),col=rainbow(6))
### Histogram - funkcje z biblioteki lattice
library("lattice") histogram(~ iris$Sepal.Width | factor(Species), data = iris)
histogram(~ weight | factor(feed), data = chickwts)
### Histogram - z zaznaczonymi pojedynczymi obserwacjami # mieszanka rozkładów normalnych # - N( 0, 1) waga 0.3 # - N( 3, 1) waga 0.7 x <- rnorm( 1000,mean = sample( c(0, 3), size = 1000, prob = c(.3, .7), replace = TRUE ) )
par( las = 1, mar = c(3,3,4,1)+.1 ) h <- hist( x, plot = FALSE, breaks = 15 ) d <- density( x ) plot( h , border = NA, freq = FALSE, xlab = "", ylab = "",main= "Use of clipping and translucency" ) usr <- par( "usr" ) ncolors <- 100 dy <- ( usr[4] - usr[3] ) / ncolors colors <- colorRampPalette( c("yellow","orange","red") )(ncolors)
# poziome linie na wykresie abline( h = axTicks(2) , col = "gray", lwd = .5 )
for( i in 1:ncolors){ clip( usr[1], usr[2], usr[3] + (i-1) * dy, usr[3] + i*dy ) plot( h, add = TRUE, axes = FALSE, ylab = "", xlab = "", col = colors[i], border = NA, freq = FALSE) } do.call( clip, as.list( usr) )
plot( h, add = TRUE, lwd = .5 , freq = FALSE, xlab = "", ylab = "", axes = FALSE ) lines( d, lwd = 4, col = "#77222288" )
#Dodanie znaczników pojedynczych obserwacji rug( x, col = "#000000FF" ) box()
|