Skip to content

Instantly share code, notes, and snippets.

View sunxm19's full-sized avatar
😃
got my web page down.

Xiangmin (Sam) sunxm19

😃
got my web page down.
  • Arizona State University
  • Phoenix, Arizona
  • 19:23 (UTC -07:00)
View GitHub Profile
@tylermorganwall
tylermorganwall / submarine_cable_map.R
Last active April 19, 2024 07:36
Submarine Cable Map Dataviz
library(geojsonsf)
library(sf)
library(rayrender)
#Data source: https://github.com/telegeography/www.submarinecablemap.com
cables = geojson_sf("cable-geo.json")
cablescene = list()
counter = 1
for(i in 1:length(cables$geometry)) {
@tomhopper
tomhopper / plot_aligned_series.R
Last active June 25, 2023 17:36
Align multiple ggplot2 graphs with a common x axis and different y axes, each with different y-axis labels.
#' When plotting multiple data series that share a common x axis but different y axes,
#' we can just plot each graph separately. This suffers from the drawback that the shared axis will typically
#' not align across graphs due to different plot margins.
#' One easy solution is to reshape2::melt() the data and use ggplot2's facet_grid() mapping. However, there is
#' no way to label individual y axes.
#' facet_grid() and facet_wrap() were designed to plot small multiples, where both x- and y-axis ranges are
#' shared acros all plots in the facetting. While the facet_ calls allow us to use different scales with
#' the \code{scales = "free"} argument, they should not be used this way.
#' A more robust approach is to the grid package grid.draw(), rbind() and ggplotGrob() to create a grid of
#' individual plots where the plot axes are properly aligned within the grid.
@darrik
darrik / pdfxtheme.reg
Created June 30, 2012 22:31
Solarized dark "theme" for PDF-XChange Viewer
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Tracker Software\PDFViewer\PageDisplay\Colors\Overrides\Custom]
"TextFill"=dword:00969483
"LineArtFill"=dword:00423607
"UseLineArt"=dword:00000001
"UseText"=dword:00000001
"LineArtStroke"=dword:00756e58
"Background"=dword:00362b00
@dholstius
dholstius / stat_rollapplyr.R
Created June 8, 2012 22:50
Apply a rolling mean (or other function) to a ggplot2 layer
require(ggplot2)
require(proto)
StatRollApplyR <- proto(ggplot2:::Stat, {
required_aes <- c("x", "y")
default_geom <- function(.) GeomLine
objname <- "rollapplyr"
calculate_groups <- function(., data, scales, ...) {
.super$calculate_groups(., data, scales, ...)
}
calculate <- function(., data, scales, width, FUN, fill=NA, ...) {