-
Notifications
You must be signed in to change notification settings - Fork 633
Update vignettes #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Update vignettes #642
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d89dbe5
few initial thoughts
cpsievert 59f176c
load package
cpsievert 3a025a6
unique tests
cpsievert 4eb63e6
obtain error message
cpsievert 97a8fe7
try assigning object to child session
cpsievert a923f9d
only diff the data and layout
cpsievert e938085
upgrade to plotlyjs 1.14.2; NEWS -> NEWS.md
cpsievert 42c0d7c
deprecate last_plot()
cpsievert 2e0030e
Duplicated values of positional attributes are no longer removed
cpsievert 5697b17
add test
cpsievert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: plotly | ||
Title: Create Interactive Web Graphics via 'plotly.js' | ||
Version: 4.0.0 | ||
Version: 4.0.1 | ||
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"), | ||
email = "[email protected]"), | ||
person("Chris", "Parmer", role = c("aut", "cph"), | ||
|
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
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
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
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
Binary file not shown.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
dependencies: | ||
- name: plotlyjs | ||
version: 1.14.1 | ||
version: 1.14.2 | ||
src: "htmlwidgets/lib/plotlyjs" | ||
script: plotly-latest.min.js | ||
stylesheet: plotly-htmlwidgets.css |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: "plotly overview" | ||
author: "Carson Sievert" | ||
date: "`r Sys.Date()`" | ||
output: | ||
rmarkdown::html_vignette: | ||
self_contained: false | ||
vignette: > | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteIndexEntry{Plotly Intro} | ||
--- | ||
|
||
```{r, echo = FALSE} | ||
knitr::opts_chunk$set( | ||
message = FALSE, | ||
warning = FALSE, | ||
fig.width = 7, | ||
fig.height = 3 | ||
) | ||
``` | ||
|
||
plotly is an R package for making interactive graphics via the open source JavaScript graphing library [plotly.js](https://github.com/plotly/plotly.js). It provides two main ways to create a plotly visualization: `ggplotly()` and `plot_ly()`. Both of these functions output an [htmlwidget](http://www.htmlwidgets.org/) object, which allows plots to work seamlessly and consistently across various contexts (e.g., R Markdown documents, shiny apps, inside RStudio, or any other R command prompt). For IPython/Jupyter notebook users, there is also an `embed_notebook()` function to embed plots as iframes pointing to a local HTML file. For [plot.ly](https://plot.ly/) subscribers, there is a `plotly_POST()` function for sending local graphs to your account, and a `get_figure()` function for downloading publicly hosted plot.ly figure(s). | ||
|
||
## Translate ggplot2 to plotly with `ggplotly()` | ||
|
||
The `ggplotly()` function translates [ggplot2](https://cran.r-project.org/web/packages/ggplot2/index.html) graphics to a plotly equivalent, for example: | ||
|
||
```{r} | ||
library(plotly) | ||
p <- ggplot(txhousing, aes(x = date, y = median, group = city)) + | ||
geom_line(alpha = 0.3) + | ||
geom_line(data = subset(txhousing, city == "Houston"), color = "red") | ||
ggplotly(p) | ||
``` | ||
|
||
If you know ggplot2, `ggplotly()` is great since you can add some interactivity (specifically, idenfication + zoom & pan) to your plots for free. Also, | ||
|
||
The `ggplotly()` function tries its best to replicate what you see _exactly_ in the static ggplot2 graph. | ||
|
||
The output of a `ggplotly()` function is a plotly object. | ||
|
||
## The `plot_ly()` interface | ||
|
||
The `plot_ly()` function draws inspiration from ggplot2's implementation of the grammar of graphics, but provides a more flexible and direct interface to [plotly.js](https://github.com/plotly/plotly.js). The interface is also functional, and designed to work with dplyr, so visualization can be described as a sequence of data manipulations and visual components via the pipe operator (`%>%`) from the magrittr package. | ||
|
||
```{r} | ||
txhousing %>% | ||
group_by(city) %>% | ||
plot_ly(x = ~date, y = ~median) %>% | ||
add_lines(alpha = 0.3, color = I("black"), name = "Texan Cities") %>% | ||
filter(city == "Houston") %>% | ||
add_lines(color = I("red"), name = "Houston") | ||
``` | ||
|
||
TODO: list resources |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't seem like this is complete