This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
anscombe_m <- data.frame() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's say you want to visually compare the peaks in a mountain range. Or you need to describe irregularities in temperature over time. But all your data is in a spreadsheet. How would you do it? | |
<br> | |
<br> | |
A map. Not just any map. A beautiful, interactive, online map. | |
<br> | |
<br> | |
This post shows how to use interactivity and maps in <a href="https://plot.ly">Plotly</a>, a new graphing and analytics platform. Our <a href="https://plot.ly/api">APIs</a> for <a href="https://plot.ly/r">R</a>, <a href="https://plot.ly/python">Python</a>, and <a href="https://plot.ly/matlab">MATLAB</a> let you collaboratively make and share plots and maps. You can make plots using <a href="https://plot.ly/ggplot2">ggplot2</a>, <a href="https://plot.ly/matplotlib">matplotlib</a>, Excel, <a href="https://github.com/plotly/Igor-Pro-Graph-Converter">Igor Pro</a>, or our web app--entirely with coding or without any. Your call. | |
<br> | |
<br> | |
<h2>1. Canadian Cities, Virginia Breweries, & Election Maps</h2> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:a326aa212906d33bcb7ceb0b0b032d7e2b352e1e16fb15f3185d5cbab6438e24" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="https://plot.ly/r">R</a>, <a href="https://plot.ly/">Plotly</a>, and <a href="https://plot.ly/ggplot2">ggplot2</a> let you make, share, and collaborate on beautiful, interactive plots online. Let's see what we can do with the topographic data from Auckland's Maunga Whau Volcano that comes with R. | |
<br> | |
<br> | |
Copy and paste this R code to make your first plot. The basic idea is: use ggplot2 code, add <code>py$ggplotly()</code> to call the Plotly API, and make an interactive, web-based plot for sharing and collaboration. | |
<br> | |
<br> | |
<div style="overflow:auto;"><div class="geshifilter"><pre class="r geshifilter-R" style="font-family:monospace;"><a href="http://inside-r.org/r-doc/utils/install.packages"><span style="color: #003399; font-weight: bold;">install.packages</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">"devtools"</span><span style="color: #009900;">)</span> <span style="color: #666666; font-style: italic;"># so we can install from github</span> | |
< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><a href="https://plot.ly">Plotly</a> is a platform for data analysis, graphing, and collaboration. You can use <a href="https://plot.ly/ggplot2">ggplot2</a>, Plotly's <a href="https://plot.ly/r">R API</a>, Plotly's web app to make and share interactive plots. The latest: you can make <a href="http://blog.plot.ly/post/101360048217/7-plotly-graphs-in-3d-stocks-cats-and-lakes">3D plots</a>. Below are a few examples; this post shows three others, made with ggplot2 and Plotly's R API.</p> | |
<br> | |
<br> | |
<center><a href="http://blog.plot.ly/post/101360048217/7-plotly-graphs-in-3d-stocks-cats-and-lakes"><img src="http://i.imgur.com/asHsC9x.png" title="3D" /></a></center> | |
<br> | |
<br> | |
First, let's convert a ggplot2 tile plane into a Plotly graph, then convert it to a 3D plot. You can copy and paste this code and use a test username and key, or <a href="https://plot.ly/ssu">sign up for an account</a> and generate your own. | |
<br> | |
<br> | |
<div style="overflow:auto;"><div class="geshifilter"><pre class="r geshifilter-R" style="f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Publishing R and interactive ggplot2 plots to the web | |
<br> | |
It's delightfully smooth to publish R code, plots, and presentations to the web. For example: | |
<ul> | |
<br> | |
<br> | |
<li type=disc><a href="http://shiny.rstudio.com/">Shiny</a> makes interactive apps from R. | |
<li type=disc><a href="www.inside-r.org/pretty-r/tool">Pretty R</a> highlights R code for HTML. | |
<li type=disc><a href="http://ramnathv.github.io/slidify/">Slidify</a> makes slides from R Markdown. | |
<li type=disc><a href="http://yihui.name/knitr/">Knitr</a> and <a href="http://rpubs.com/">RPubs</a> let you publish R Markdown docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:9e47f585a71968836bac78e306741c43f75b94539318afaad4dd4cad9eff3bcd" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How do people use Plotly? Google Chrome ships a Plotly <a href="https://chrome.google.com/webstore/detail/plotly/hfjjbcodmdgnpngccdnefheadifbmmei">Chrome App</a> for high schoolers and businesses. NASA scientists and engineers track satellites with Plotly. Journalists at the Washington Post and Wired explain current events with Plotly. How can you use Plotly? Read on to learn more about our free online product or see a <a href="https://plot.ly/product/enterprise/">product page</a> to learn about how to run Plotly on your own servers. | |
<br> | |
<br> | |
Let's jump in. A Plotly version of a <a href="https://www.facebook.com/notes/facebook-data-science/mothers-day-2014/10152235539518859">Facebook Data Science team</a> graph shows the age of children on the x axis and the distance between children and mothers on the y axis. | |
<br> | |
<br> | |
<iframe width="650" height="650" frameborder="0" seamless="seamless" scrolling="no" src="https://plot.ly/~cimar/38/.embed?width=650&height=650"></iframe> | |
<br> | |
<br> | |
Move your mouse over the g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>You can embed interactive Plotly graphs in your webpage or blog with this HTML snippet. Add the desired URL and re-size as needed.</p> | |
<br> | |
<pre style="background:#f1f1f1;color:#000"><iframe src=<span style="color:#c03030">"https://plot.ly/~cimar/114/650/650"</span> width=<span style="color:#c03030">"650"</span> height=<span style="color:#c03030">"650"</span> frameBorder=<span style="color:#c03030">"0"</span> seamless=<span style="color:#c03030">"seamless"</span> scrolling=<span style="color:#c03030">"no"</span>></iframe> | |
</span></pre> | |
<div width="100%" align="center"><p>***</p></div> | |
<br> | |
<br> | |
<img src="https://31.media.tumblr.com/8b02b31fc6bdf3b17b24fee080dec36e/tumblr_inline_n9eb6jUByn1suclhk.png"> | |
<br> | |
<br> |