Amazing plot: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 74: Line 74:
= Mosaic =
= Mosaic =
[https://rviews.rstudio.com/2020/02/13/photo-mosaics-in-r/ Photo Mosaics in R]
[https://rviews.rstudio.com/2020/02/13/photo-mosaics-in-r/ Photo Mosaics in R]
= Analog clock =
[https://tomaztsql.wordpress.com/2021/09/16/little-useless-useful-r-functions-useless-analog-and-digital-clocks/ Useless analog and digital clocks]

Revision as of 16:47, 19 September 2021

New R logo 2/11/2016

library(sp)
library(maptools)
library(ggplot2)
library(ggthemes)
# rgeos requires the installation of GEOS from http://trac.osgeo.org/geos/
system("curl http://download.osgeo.org/geos/geos-3.5.0.tar.bz2 | tar jx")
system("cd geos-3.5.0; ./configure; make; sudo make install")
library(rgeos)
 
r_wkt_gist_file <- "https://gist.githubusercontent.com/hrbrmstr/07d0ccf14c2ff109f55a/raw/db274a39b8f024468f8550d7aeaabb83c576f7ef/rlogo.wkt"
if (!file.exists("rlogo.wkt")) download.file(r_wkt_gist_file, "rlogo.wkt")
rlogo <- readWKT(paste0(readLines("rlogo.wkt", warn=FALSE))) # rgeos
 
rlogo_shp <- SpatialPolygonsDataFrame(rlogo, data.frame(poly=c("halo", "r"))) # sp
rlogo_poly <- fortify(rlogo_shp, region="poly") # ggplot2
 
ggplot(rlogo_poly) + 
  geom_polygon(aes(x=long, y=lat, group=id, fill=id)) + 
  scale_fill_manual(values=c(halo="#b8babf", r="#1e63b5")) +
  coord_equal() + 
  theme_map() + 
  theme(legend.position="none")

3D plot

Using persp function to create the following plot. Code in github.

3dpersp.png

Christmas tree

http://wiekvoet.blogspot.com/2014/12/merry-christmas.html. Code in github.

XMastree.png

Happy Thanksgiving

Turkey

Turkey.png

Happy Valentine's Day

treemap

http://ipub.com/treemap/

TreemapPop.png

Voronoi diagram

Silent Night

Silentnight.png

The code in github.

The Travelling Salesman Portrait

https://fronkonstin.com/2018/04/04/the-travelling-salesman-portrait/

Moon phase calendar

https://chichacha.netlify.com/2018/05/26/making-calendar-with-ggplot-moon-phase-calendar/

Calendar heatmap

https://stackoverflow.com/questions/26171068/add-dates-to-calendar-heat-map-r

Chaos

Rcpp, Camarón de la Isla and the Beauty of Maths

Mosaic

Photo Mosaics in R

Analog clock

Useless analog and digital clocks