Вы находитесь на странице: 1из 2

ggplot(dataset, aes(x = , y = , color = clarity, size =, shape =,)) +

geom_point(pode colocar alpha = 0.4 p/ transpar�ncia ) + geom_smooth()


# geom_smooth � linha da m�dia,

ggplot(mtcars, aes(x = wt, y = mpg, col = cyl)) +


geom_point() +
geom_smooth(method = "lm", se = FALSE) + geom_smooth(aes(group = 1), method =
"lm", se = FALSE, linetype = 2)
# plot pra cores diferentes, regress�o linear dividido entre cores e um geral

ggplot(iris.tidy, aes(x = Species, y = Value, col = Part)) +


geom_jitter() +
facet_grid(. ~ Measure)
#geom_jitter � tipo ggplot, facet_grid � dividir por visualiza��es diferentes

ggplot(dataset, aes(x, y, color, fill, size, alpha, labels))


# s�o esses par�metros do aesthetics

ggplot(mtcars, aes(x = wt, y = mpg, fill = cyl, col = am)) +


geom_point(shape = 21, size = 4, alpha = 0.6)
# nesse caso geom_point define a forma de plotar

###################################################################################
###################################################################################
#########################
# Map cyl to size
ggplot(mtcars, aes(x = wt, y = mpg, size = cyl )) + geom_point()

# Map cyl to alpha


ggplot(mtcars, aes(x = wt, y = mpg, alpha = cyl )) + geom_point()

# Map cyl to shape


ggplot(mtcars, aes(x = wt, y = mpg, shape = cyl )) + geom_point()

# Map cyl to label


ggplot(mtcars, aes(x = wt, y = mpg, label = cyl )) + geom_text()
#plotar usando par�metros diferentes p/ explicar cyl

###################################################################################
###################################################################################
#############################

#gr�fico de barras
cyl.am <- ggplot(mtcars, aes(x = factor(cyl), fill = factor(am)))
cyl.am +
geom_bar(position = "stack" ou "fill" ou "dodge")

#histograma
ggplot(dataset, aes(qualquer coisa)) +
geom_histogram()
#by deafult, goem_histogram(count), mas pode colocar bindwidth, aes(y = ???),
bindwidth = 1, fill = "alguma cor(?)"
#Uma forma de overlap
ggplot(mtcars, aes(x = cyl, fill = am)) +
geom_bar(position = posn_d, alpha = 0.6)

#outra forma de overlap


ggplot(mtcars, aes(mpg, col = cyl)) +
geom_freqpoly(binwidth = 1, position = "identity")

#Time-series
ggplot(economics, aes(x = date, y = unemploy)) +
geom_line()
#Time-series com recess�o
ggplot(economics, aes(x = date, y = unemploy/pop)) +
geom_rect(data = recess, aes(xmin = begin, xmax = end, ymin = -Inf, ymax = +Inf),
inherit.aes = FALSE,
fill = "red", alpha = 0.2) +
geom_line()

#Multiple Time-Series

str(fish.species)
fish.tidy <- gather(fish.species, Species, Capture, -Year)
ggplot(fish.tidy, aes(x = Year, y = Capture, color = Species)) + geom_line()

#T� ficando cabuloso


ggplot(Vocab, aes(x = education, y = vocabulary, col = year, group = factor(year)))
+
stat_smooth(method = "lm", se = FALSE, alpha = 0.6, size = 2) +
scale_color_gradientn(colors = brewer.pal(9, "YlOrRd"))

Вам также может понравиться