Skip to content

Instantly share code, notes, and snippets.

@weiglemc
Last active July 14, 2017 16:28
Show Gist options
  • Save weiglemc/1b8dbc563de5ff55afb8 to your computer and use it in GitHub Desktop.
Save weiglemc/1b8dbc563de5ff55afb8 to your computer and use it in GitHub Desktop.
Murray example

Working through the examples from Scott Murray's tutorial at http://alignedleft.com/tutorials/d3/

Built with blockbuilder.org

Image and code from http://www.harding.edu/fmccown/r/

Embedding an image in Markdown:

R image

Embedding R code in Markdown:

# Define 2 vectors
cars <- c(1, 3, 6, 4, 9)
trucks <- c(2, 5, 4, 5, 12)

# Graph cars using a y axis that ranges from 0 to 12
plot(cars, type="o", col="blue", ylim=c(0,12))

# Graph trucks with red dashed line and square points
lines(trucks, type="o", pch=22, lty=2, col="red")

# Create a title with a red, bold/italic font
title(main="Autos", col.main="red", font.main=4)
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width:100%; height: 100% }
</style>
</head>
<body>
<script>
d3.select("body").append("p").text("New paragraph!");
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment