|
3 | 3 | \alias{plotly} |
4 | 4 | \title{Main interface to plotly} |
5 | 5 | \usage{ |
6 | | -plotly(username = NULL, key = NULL) |
| 6 | +plotly(username = NULL, key = NULL, base.url = "https://plot.ly") |
7 | 7 | } |
8 | 8 | \arguments{ |
9 | 9 | \item{username}{plotly username} |
10 | 10 |
|
11 | 11 | \item{key}{plotly API key} |
| 12 | + |
| 13 | +\item{base.url}{plotly server} |
12 | 14 | } |
13 | 15 | \value{ |
14 | | -An object of class PlotlyClass, except for the final object after adding |
15 | | -layers becomes a list class. |
| 16 | +An object of class PlotlyClass, except for the final object after |
| 17 | +adding layers becomes a list class. |
16 | 18 | } |
17 | 19 | \description{ |
18 | | -A call to \code{plotly(username, key)} creates an object of class 'PlotlyClass', which |
19 | | -has 3 methods: |
| 20 | +A call to \code{plotly(username, key)} creates an object of class |
| 21 | +'PlotlyClass', which has methods: |
20 | 22 | \itemize{ |
21 | | - \item Plotting: py$plotly(x1, y1[,x2,y2,...], kwargs=kw) or |
22 | | - py$plotly({data1[,data2,...]}, kwargs=kwargs) |
| 23 | + \item Plotting: py$plotly(x1, y1[, x2, y2, ...], kwargs=kwargs) or |
| 24 | + py$plotly({data1[, data2, ...]}, kwargs=kwargs), py$ggplotly() |
23 | 25 | \item Styling Data: py$style(data1,data2,..., kwargs=kwargs) |
24 | 26 | \item Styling Layout: py$layout(layout, kwargs=kwargs) |
| 27 | + \item Utilities: py$get_figure(file_owner, file_id) |
25 | 28 | } |
26 | 29 | } |
27 | 30 | \details{ |
28 | | -Plotly interface object. See up-to-date documentation and examples at https://plot.ly/API |
| 31 | +Plotly interface object. See up-to-date documentation and examples at |
| 32 | +https://plot.ly/API |
29 | 33 |
|
30 | 34 | See documentation and examples at https://plot.ly/API |
31 | 35 | } |
32 | 36 | \examples{ |
33 | 37 | \dontrun{ |
34 | 38 | ## View https://plot.ly/API for more examples |
35 | 39 | ## Generate a simple plot |
36 | | -username <- 'anna.lyst' # fill in with your plotly username |
37 | | -api_key <- 'y37zkd' # fill in with your plotly API key |
| 40 | +username <- 'anna.lyst' # fill in with your plotly username |
| 41 | +api_key <- 'y37zkd' # fill in with your plotly API key |
38 | 42 | py <- plotly(username, api_key) |
39 | 43 | ## generate some data |
40 | | -x <- c(0,1,2) |
41 | | -y <- c(10,11,12) |
| 44 | +x <- c(0, 1, 2) |
| 45 | +y <- c(10, 11, 12) |
42 | 46 |
|
43 | | -## Send data to Plotly. Plotly will render an interactive graph and will return a |
44 | | -## URL where you can view your plot |
| 47 | +## Send data to Plotly. Plotly will render an interactive graph and will |
| 48 | +## return a URL where you can view your plot |
45 | 49 | ## This call sends data to Plotly, Plotly renders an interactive |
46 | | -## graph, and returns a URL where you can view your plot |
47 | | -response <- py$plot(x,y) |
48 | | -response$url # view your plot at this URL |
49 | | -browseURL(response$url) # use browseURL to go to the URL in your browser |
| 50 | +## graph, and returns a URL where you can view your plot |
| 51 | +response <- py$plot(x, y) |
| 52 | +response$url # view your plot at this URL |
| 53 | +browseURL(response$url) # use browseURL to go to the URL in your browser |
50 | 54 |
|
51 | | -## Export ggplots directly to plot.ly. |
| 55 | +## Export ggplots directly to plot.ly |
52 | 56 | ggiris <- qplot(Petal.Width, Sepal.Length, data=iris, color=Species) |
53 | 57 | py$ggplotly(ggiris) |
54 | 58 | data(canada.cities, package="maps") |
55 | | -viz <- ggplot(canada.cities, aes(long, lat))+ |
56 | | - borders(regions="canada", name="borders")+ |
57 | | - coord_equal()+ |
| 59 | +viz <- ggplot(canada.cities, aes(long, lat)) + |
| 60 | + borders(regions="canada", name="borders") + |
| 61 | + coord_equal() + |
58 | 62 | geom_point(aes(text=name, size=pop), colour="red", |
59 | 63 | alpha=1/2, name="cities") |
60 | 64 | py$ggplotly(viz) |
|
0 commit comments