Load Necessary Packages
library(rgdal)
library(ggplot2)
library(ggmap)
library(raster)
require(ggridges)
require(ggjoy)
Open ASCII file using raster command
map <- raster("Farallons2mtopo.asc") #elevation data of sefi
#convert the raster to points for plotting
map.p <- rasterToPoints(map)
#Make the points a dataframe for ggplot
df <- data.frame(map.p)
#Make appropriate column headings
colnames(df) <- c("Longitude", "Latitude", "MAP")
# subset for boundaries of plot
d<-subset(df,Latitude<4173000&Latitude>4171800&Longitude<500100&Longitude>498700)
Trim the number of lines of latitude to plot
toDelete <- seq(1, nrow(d), 2)
dfr<-d[toDelete,]
Create a new dataframe to plot horizontal zero lines
# length of latitude
lat<-seq(4171801,4173051,6)
# make a dataframe to plot zero lines
zeros<-data.frame(Latitude=rep(lat,2),Longitude=c(rep(498700,length(lat)),
rep(500100,length(lat))),MAP=rep(0.1,length(lat)*2))
Lenghty ggplot code to produce the plot
line.map <- ggplot() +
geom_ridgeline(data=zeros, aes(x=Longitude, y=Latitude, height = MAP, group = Latitude),
size=0.09,fill="black",color="grey60",na.rm = FALSE)+
geom_ridgeline(data=dfr, aes(x=Longitude, y=Latitude, height = MAP, group = Latitude),
size=0.12,min_height=4,fill="black",color="white",na.rm = FALSE)+
coord_fixed(0.9)+
theme_bw()+
theme(panel.background = element_rect(fill = "black"))+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.border = element_blank())
line.map
Save as a .png file to your working directory
png(file=paste("sefi.ridge.map",format(Sys.time(), "%Y-%m-%d"), "png", sep = "."), units="in",width=6,height=6,res=700)
line.map
dev.off()