May 16, 2022

lattice ggthemes ggraph ggmap cowplot Packages in R

R Packages - lattice ggthemes ggraph ggmap cowplot

library(ggthemes)

p4 + theme_tufte(ticks=FALSE) + geom_tufteboxplot()
p4 + theme_tufte(ticks=FALSE) +
  geom_tufteboxplot(median.type = "line")
p4 + theme_tufte(ticks=FALSE) +
  geom_tufteboxplot(median.type = "line", whisker.type = 'line', hoffset = 0, width = 3)
p2 + theme_economist() + scale_colour_economist() +
  scale_y_continuous(position = "right")
p2 + theme_excel() + scale_colour_excel()
p2 + theme_few() + scale_colour_few()
p2 + theme_wsj() + scale_colour_wsj("colors6", "")
p2 + geom_smooth(method = "lm", se = FALSE) +
  scale_color_ptol("cyl") +
  theme_minimal()
ggplot(diamonds, aes(x = clarity, fill = cut)) +
  geom_bar() +
  theme_pander() +
  scale_fill_pander()
ggplot() +
  geom_map(data  =  us, map = us,
           aes(x = long, y = lat, map_id = region, group = group),
           fill = "white", color = "black", size = 0.25) +
  coord_map("albers", lat0 = 39, lat1 = 45) +
  theme_map()
show_col(canva_pal("Timeless and nautical")(4))
p2 + theme_solarized() + scale_colour_solarized("blue")
p2 + theme_stata() + scale_colour_stata()
ggplot(diamonds, aes(x = clarity, fill = cut)) +
  geom_bar() +
  scale_fill_excel() +
  theme_excel()

library(ggraph)

graph <- graph_from_data_frame(highschool)
ggraph(graph, layout = 'kk') +
    geom_edge_fan(aes(alpha = ..index..), show.legend = FALSE) +
    geom_node_point(aes(size = Popularity)) +
    facet_edges(~year) +
    theme_graph(foreground = 'steelblue', fg_text_colour = 'white')

library(igraph)


library(grid)

pushViewport(plotViewport())
pushViewport(viewport(layout = grid.layout(2, 2)))
pushViewport(dataViewport(x,y))
grid.rect()
grid.xaxis()
grid.yaxis()
grid.points()
grid.text("Cereal", x=unit(-3, "lines"), rot=90)
popViewport(2)
ggsave("multipage.pdf", ml)
ggsave('priceHistogram.png')
ggsave( filename = "myplot.png", plot = d )
ggplot2::ggsave(filename="TestPredAgainstActualsQuickPlot.jpg", plot=ggplotTestPredAgainstActualsQuick, dpi=1200, device="jpeg")
g <- ngonGrob(unit(xy[,1],"cm") + unit(0.5,"npc"), unit(xy[,2],"cm") + unit(0.5,"npc"), n = seq_len(N) + 2, gp = gpar(fill=1:N))
g3 <- ellipseGrob(unit(xy[,1],"cm") + unit(0.5,"npc"), unit(xy[,2],"cm") + unit(0.5,"npc"), angle = -2*seq(0,N-1)*p
grid.draw(g)

library(gridExtra) # Placing ggplot2 graphs side by side

grid.arrange(plot1, plot2, plot3, plot4)
grid.arrange(p1, p2, p3, p4, ncol=2)
grid.arrange(humDist, bareDist, nrow=2)
grid.table(round(a, digits=3))
grid.newpage()

library(ggmap)

geocode("United States")
map <- get_map(location = 'Europe', zoom = 4)
NYCMap <- get_map("New York", zoom = 10)
map.data <- get_map(location=c(lon=-0.161, lat=65.78), color="color", source="google", maptype="satellite", zoom=12)
map.data <- get_map(location=c(lon=-92.15, lat=24.86), color="color", source="google", maptype="roadmap", zoom=16)
map.data <- get_map(location=c(lon=-35.82, lat=47.69), color="color", source="google", maptype="hybrid", zoom=8)
ggmap(map.data, extent="panel", ylab="Latitude", xlab="Longitude")
ggmap(get_map(location=usa_geo_code, source="google", zoom=4), extent="panel")
ggmap(get_map(location=geo_codes, zoom=6), extent="panel")
  + geom_point(aes(x=lon, y=lat), data=collisions, col="red", alpha=0.4, size=coll$collisions*0.05)
world<-map_data("world")
map<-ggplot()+geom_map(data=world,map=world, aes(x=long,y=lat,map_id=region), color='#333300', fill='#663300')
mapPoints <- ggmap(map) + geom_point(aes(x = lon, y = lat, size = sqrt(flights)), data = airportD, alpha = .5)

library(maps)

map("state",c('New York','massachusetts','Pennsylvania'),fill=TRUE,col="dark green",projection="polyconic")
library(mapdata)

library(googleway)

places <- google_places(search_string="hospital", location=c(0.06, -52.094), radius=50000, key=key)
places$results$name
places$results$formatted_address
places$results$geometry$location

library(gganimate)

gganimate(p)

library(animation)

ani.options(interval=0.15)
ani.options(nmax = 70)
vi.grid.illusion(type = "h", lwd = 22, nrow = 5, ncol = 5, col = "white")
vi.lilac.chaser()
grad.desc(f2, c(-2, -2, 2, 2), c(-1, 0.5), gamma = 0.3, tol = 1e-04)
kmeans.ani(x, centers = 2)
knn.ani(train = x, test = y, cl = rep(c("first class", "second class"),  each = 40), k = 30)
knn.ani(train = x, test = y, cl = rep(c("first", "second", "third"), each = 15), k = 25, cl.pch = c(2, 3, 19), dist.lty = 3)

library("lattice")

histogram(~Sepal.Length | Species, xlab="", data=iris, layout=c(3,1), type="density", main="Lattice Histogram", sub="Iris Dataset, Sepal Length")
histogram(data=scores, ~scroe|company, main="Sentiment Analysis", col=c("red", "grey"), xlab="", sub="Sentiment Score")
QQ plots - Quantile - Quantile plots
qqmath(~Sepal.Length | Species, data=iris)
qqmath(~Sepal.Length | Species, data=iris, distribution=qunif)
bwplot(Specis~Sepal.Length, data=iris) # box plot
bwplot(Specis~Sepal.Length, data=iris, panel=panel.violin) # violin plot
boxplot(score~company, data=scores, col=c("red", "grey")
with(mtcars, xyplot(wt~mpg, group=cyl, auto.key=T, pch=20, cex=3))
xyplot(rate.female~rate.male, data=USCancerRates)
xyplot(dt$y~dt$x, cex = dt$Freq^2, col =dt$Freq)
histogram(~rate.male, data=USCancerRates)
levelplot(formula, data, at, contour = FALSE, cuts = 15, pretty = FALSE, region = TRUE, ..., col.regions = trellis.par.get("regions")$col, colorkey = region)
levelplot(cor(mtcars))
levelplot(cor(curr[,c(3:6,8,20)]))
levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="", ylab="", main="Weird Function", sub="with log scales", colorkey = FALSE, region = TRUE)
levelplot(cor, main="stage 12-14 array correlation matrix", xlab="", ylab="", col.regions=rgb.palette(120), cuts=100, at=seq(0,1,0.01))
contourplot(formula, data, at, contour = TRUE, labels = format(at), cuts = 7, pretty = TRUE, ...)
contourplot(fit ~ wind * temperature | radiation, data = grid, cuts = 10, region = TRUE, xlab = "Wind Speed (mph)", ylab = "Temperature (F)", main = "Cube Root Ozone (cube root ppb)")         

install.packages("plotrix")

ablineclip(v=1, lty=1, col="sienna2", lwd=2)
ablineclip(v=4, lty=4, col="sienna2", lwd=5)
twoord.plot( lx=media$day,ly=media$Views_show,ry=media$Ad_impression, rx = media$day, ylab="Views_show",rylab="Ad_impression") # to generate a plot with 2 Y axis

require(cowplot)

plot_grid(plot1, plot2, align = "none", nrow = 2, ncol = 3, axis = "r", scale = 1, labels = "AUTO")
plot_grid(plot1, plot2, align='h', labels=c('A', 'B'))
cowplot::plot_grid(A, B, labels = c("A", "B"), align = "v")
plot_grid(ggplot(telecom, aes(MonthlyCharges))+ geom_histogram(binwidth = 20),
          ggplot(telecom, aes(x="", y=MonthlyCharges))+ geom_boxplot(width=0.1) + coord_flip() + box_theme,
          align = "v", ncol = 1)

library(GGally)

ggpairs(telecom[, c("tenure", "MonthlyCharges", "TotalCharges")])
ggpairs(car_price[, names(select_if(car_price[,-1], is.numeric))])

library(rgl)

plot3d(swiss.pca$x[,1:3],type="s",size=.25, col=swiss.4m$cluster)

library(ggbeeswarm)

ggplot(GaltonFamilies,  aes(gender, childHeight)) +
  geom_boxplot() + geom_quasirandom(alpha = 0.05) + theme_bw()
ggplot(ts, aes(Market.Segment, Monthly_Profits)) +
  geom_boxplot() + geom_quasirandom(alpha = 0.05) + theme_bw() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 0.5), legend.position="none")

Related aRticles:  ggplot2 package in R  R dplyr package


No comments:

Post a Comment