Skip to content

Instantly share code, notes, and snippets.

View msund's full-sized avatar
🪴

Matthew Sundquist msund

🪴
View GitHub Profile
install.packages("devtools") # so we can install from github
library("devtools")
install_github("ropensci/plotly") # plotly is part of ropensci
library(plotly)
py <- plotly(username="r_user_guide", key="mw5isa4yqp") # open plotly connection
library(ggplot2)
d <- 1:9
prob = log10(1 + (1/d))
We've paid these famous graphs our sincerest form of compliment: trying to re-make them for the web. This post is inspired by <a href="http://www.edwardtufte.com/tufte/">Edward Tufte</a>. The plots were made with our free online product--you can press "play with this data" and start editing your own copy online. We have <a href="https://plot.ly/learn">tutorials</a> for using our web product and <a href="https://plot.ly/api">APIs</a>; contact us if you're interested in a trial of <a href="https://plot.ly/product/enterprise/">plotly on-premise</a>.
<br>
<br>
<br>
<h3>March on Moscow</h3>
<br>
<br>
<a href="http://www.edwardtufte.com/tufte/minard-obit">Charles Minard</a>'s graph of the March on Moscow shows the dwindling size of Napoleon's army. The broad tan line shows the army's size on the March from Poland to Moscow. The lower, thinner, dark line shows the army's size on the retreat. The width of the lines shows the army size, which started over 400,000 strong and dwindled to 10,000. The bottom lines show t
{
"metadata": {
"name": "",
"signature": "sha256:351fbe3baacf51974290f71f8bd183e52646887aad2bcba2182c4ced6cdfa1d2"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "",
"signature": "sha256:351fbe3baacf51974290f71f8bd183e52646887aad2bcba2182c4ced6cdfa1d2"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@msund
msund / gist:2876259bdff23164576c
Created January 27, 2015 07:09
Mountains in 3D
{
"metadata": {
"name": "",
"signature": "sha256:15fd2371553953bcf0af1f468b8ba403a3efd0f6e14d36f8fb29441b703324f4"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "",
"signature": "sha256:accbf07ab64ce1adbac7177a8bfba0c1021ed33763bd3996723564b3a71e6a37"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "",
"signature": "sha256:57e3953da6a8dc30a7f1354c37962b066401ca7fca37594140131e09720176cc"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@msund
msund / gist:4d188b1e736e0e0fe78b
Created February 13, 2015 20:47
HTML for Joe
Imagine exploring graphs like you would explore terrain on Google Maps. You would want to zoom, toggle, see data when you hover your mouse, and filter. For viewers, this is more engaging, informative, and fun. For exploration, it's more precise and efficient. Unfortunately, creating interactive plots can be difficult, time-consuming, and a technical burden.
<br>
<br>
<br>
<a href="https://plot.ly/">Plotly</a> converts ggplot2 plots into interactive, online plots rendered with D3.js, a JavaScript visualizaiton library. Letting you publish interactive ggplot2 plots with one line of code is the goal behind our project. Plotly is free and online, or can be hosted (or <a href="https://plot.ly/product/enterprise/">host Plotly</a> on your servers).
<br>
<br>
<br>
Let's make a histogram, bar chart, and boxplot. You can copy and paste this code into your R terminal to make an <a href="http://stackoverflow.com/questions/6957549/overlaying-histograms-with-ggplot2-in-r">overlad histogram</a>. <a href="https://plot.ly/gg
{
"metadata": {
"name": "",
"signature": "sha256:48ea41fd994af6da00a65cf7aa56252c9de1a3a2470ffbed1c6c6fe7c7ce6a21"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@msund
msund / gist:5481bd48a21e9532a36f
Last active August 29, 2015 14:16
Next Version for CartoDB
{
"metadata": {
"name": "",
"signature": "sha256:125dfe0d83824b70aef36b1d777d19fa4bf5ba3bde0874041ba6bd5b9a4e4aa8"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [