Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An interactive graphing library for R

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

plotly/plotly.R

Repository files navigation

R-CMD-checkCRAN StatusCRAN Downloadsmonthly

An R package for creating interactive web graphics via the open sourceJavaScript graphing libraryplotly.js.

Maintained by the Plotly Community

Installation

Install from CRAN:

install.packages("plotly")

Or install the latest development version (on GitHub) via{remotes}:

remotes::install_github("plotly/plotly")

Getting started

Web-based ggplot2 graphics

If you useggplot2,ggplotly()converts your static plots to an interactive web-based version!

library(plotly)g<- ggplot(faithful, aes(x=eruptions,y=waiting))+  stat_density_2d(aes(fill=..level..),geom="polygon")+   xlim(1,6)+ ylim(40,100)ggplotly(g)

https://i.imgur.com/G1rSArP.gifv

By default,ggplotly() tries to replicate the static ggplot2 versionexactly (before any interaction occurs), but sometimes you need greatercontrol over the interactive behavior. Theggplotly() function itselfhas some convenient “high-level” arguments, such asdynamicTicks,which tells plotly.js to dynamically recompute axes, when appropriate.Thestyle() function also comes in handy formodifying theunderlying traceattributes (e.g.hoveron) used to generate the plot:

gg<- ggplotly(g,dynamicTicks="y")style(gg,hoveron="points",hoverinfo="x+y+text",hoverlabel=list(bgcolor="white"))

https://i.imgur.com/qRvLgea.gifv

Moreover, sinceggplotly() returns a plotly object, you can applyessentially any function from the R package on that object. Some usefulones includelayout() (forcustomizing thelayout),add_traces() (and its higher-leveladd_*() siblings, for exampleadd_polygons(), foradding newtraces/data),subplot() (forcombining multiple plotlyobjects),andplotly_json() (for inspecting the underlying JSON sent toplotly.js).

Theggplotly() function will also respect some “unofficial”ggplot2 aesthetics, namelytext (forcustomizing thetooltip),frame (forcreatinganimations),andids (for ensuring sensible smooth transitions).

Using plotly without ggplot2

Theplot_ly() function provides a more direct interface to plotly.jsso you can leverage more specialized chart types (e.g.,parallelcoordinates ormaps) or even some visualization that theggplot2 API won’t ever support (e.g., surface,mesh,trisurf, etc).

plot_ly(z=~volcano,type="surface")

https://plotly.com/~brnvg/1134

Learn more

To learn more about special features that the plotly R package provides (e.g.,client-side linking,shiny integration,editing and generating static images,custom events in JavaScript, and more), seehttps://plotly-r.com. You may already be familiar with existing plotly documentation (e.g.,https://plotly.com/r/), which is essentially a language-agnostic how-to guide for learning plotly.js, whereashttps://plotly-r.com is meant to be more wholistic tutorial written by and for the R user. The package itself ships with a number of demos (list them by runningdemo(package = "plotly")) and shiny/rmarkdown examples (list them by runningplotly_example("shiny") orplotly_example("rmd")).Carson also keeps numerousslide decks with useful examples and concepts.

Contributing

Please read through ourcontributingguidelines.Included are directions for opening issues, asking questions,contributing changes to plotly, and our code ofconduct.

About

An interactive graphing library for R

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors58


[8]ページ先頭

©2009-2025 Movatter.jp