r functions: city skylines

Summary

An artistic rendering of Boston's skyline using R. Code and source data are included.

boston city skyline in polar coordinates

Been interested in using R (or other programming languages) to make artistic renderings of data—that is, representations that might not be as informative as well-made graphs, but are pleasing to look at purely for enjoyment. Took a stab at it earlier this year when representing usage statistics of a music group (club coat check member statistics) and for Cheyne-Stokes respiration. Wanted to make an artistic rendering of Boston's city skyline, again leaning on the use of polar coordinates as it is visually more interesting that using Cartesian. The code and csv file are included below.

boston building height csv files

download city_skylines_boston.R

R / S+
  1. # makes an artistic rendering of the boston city skyline
  2. # biafra ahanonu
  3. # updated: 2013.12.28
  4.  
  5. main <-function(inputFile,savePlot=1,saveFilename="city_skyline_boston.png",nrow=2,ncol=5,...){
  6.         # load in the data
  7.         dataFile = read.table(inputFile,sep=",",header=T);
  8.         # randomly group the buildings
  9.         dataFile$cat = round(runif(nrow(dataFile),1,nrow))
  10.         dataFile$scat = round(runif(nrow(dataFile),1,ncol))
  11.         # plot the data
  12.         cityPlot = ggplot(dataFile,aes(x=sample(c(nrow(dataFile))),y=stories,fill=building))+
  13.         scale_fill_hue()+
  14.         guides(fill=FALSE,group=FALSE)+
  15.         geom_bar(stat="identity",position="dodge")+
  16.         theme(
  17.                 axis.text.x = element_text(angle=90,hjust=1,vjust=.5,color="white"),
  18.                 panel.background=element_rect(fill="white",colour="white"),
  19.                 strip.text = element_blank(),
  20.                 strip.background = element_blank(),
  21.                 panel.grid = element_blank(),
  22.                 axis.text = element_blank(),
  23.                 axis.ticks = element_blank(),
  24.                 axis.title = element_blank()
  25.                 )+
  26.         facet_grid(cat~scat)+
  27.         coord_polar()
  28.  
  29.         # decide whether to save or display plot
  30.         if(savePlot==1){
  31.                 png(paste(saveFilename,sep=""),width=2400,height=2400,res=400,pointsize=1,antialias = "cleartype")
  32.                         print(cityPlot)
  33.                         # makeFootnote()
  34.                 dev.off()
  35.         }else{
  36.                 print(cityPlot)
  37.         }
  38. }
  39.  
  40. # run script
  41. main("buildings.height.boston.csv");

-biafra
bahanonu [at] alum.mit.edu

more articles to enjoy:

graduate student resources
19 august 2015 | graduate school

Providing links to some articles and other resources that I have found useful while in graduate school. I'll continually update the list as[...] I find more.

stanford bing concert hall: first impressions
15 december 2012 | stanford

Designed by architect Richard Olcott (Ennead Architects) and sound designer Dr. Yasuhisa T[...]oyota (Nagata Acoustics), the Bing Concert Hall is stunning. Robert Campbell (Fisher Dachs Associates) was on hand during the second sound check (along with Richard and Dr. Toyota) to discuss the philosophy behind the building, a bit of history, and where they hope it will be in the future. This post is my impressions of the place along with notes from their interview.

the evolving style
29 march 2012 | design

This website was built from scratch using only Notepad. While it would have been easier to create the site in Dreamweaver or another pr[...]ogram and then upload it, I wanted to learn first-hand about the steps involved in web development. The site has allowed me to hone my design skills, both aesthetically and organizationally. This is an essay detailing the evolution of the website.

This was an internal document for me to keep track of what I was changing and why, but decided to reword it and make it an article. Hope you like it.

©2006-2025 | Site created & coded by Biafra Ahanonu | Updated 21 October 2024
biafra ahanonu