plotly

Adding custom tooltip to plotly using R and ggplot2 syntax

那年仲夏 提交于 2019-12-20 03:06:53
问题 I am trying to create a plotly plot from R using a ggplot object, which has custom labels. #library('devtools') #install_github("ropensci/plotly") library('plotly') set_credentials_file(username="your_name", api_key="your_key") py <- plotly() labels = LETTERS[sample(x=26, size=nrow(iris), replace=T)] ggiris <- ggplot(iris, aes(Petal.Width, Sepal.Length, color = Species)) + geom_point() r <- py$ggplotly(ggiris) r$response I would like that the value for a particular data-point would be taken

Custom hoverinfo text on plotly R chart that is different to the 'text' parameter? [closed]

回眸只為那壹抹淺笑 提交于 2019-12-20 02:26:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have been trying to create a network graph with the plotly R library. I would like to visualize a custom hoverinfo text that is different from the text label defined for the markers (or nodes in this case). Basically, I would like to keep the text labels on the markers (nodes) as they are currently but also be

Plotly.js Choropleth map size

只愿长相守 提交于 2019-12-20 02:09:32
问题 I'm trying to make a choropleth map, but how can I set the size of the map? Now I've this map: I would like expand the map to all the space, I read the documentations but I didn't find a solution. This is my code: var data = [{ type: 'choropleth', locationmode: 'country names', locations: unpack(output, 'label'), z: unpack(output, 'nres'), text: unpack(output, 'nres') }]; var layout = { geo: { projection: { type: 'equirectangular' } } }; Plotly.plot(mapChoropleth, data, layout, { showLink:

Plotly.js Choropleth map size

南笙酒味 提交于 2019-12-20 02:09:09
问题 I'm trying to make a choropleth map, but how can I set the size of the map? Now I've this map: I would like expand the map to all the space, I read the documentations but I didn't find a solution. This is my code: var data = [{ type: 'choropleth', locationmode: 'country names', locations: unpack(output, 'label'), z: unpack(output, 'nres'), text: unpack(output, 'nres') }]; var layout = { geo: { projection: { type: 'equirectangular' } } }; Plotly.plot(mapChoropleth, data, layout, { showLink:

Color 3D Surface Based on Categories that passes through scatter points

天涯浪子 提交于 2019-12-19 11:55:33
问题 I have the data in the following format: X,Y,Z,Category I used plotly to generate a scatter plot and then a fit a Curve through the scatter points using the following code. from scipy.interpolate import griddata import numpy as np import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D x=np.asarray([3,5,9,3,3,7,6,9,1,9]); y=np.asarray([4,3,3,10,8,2,4,10,9,3]); z=np.asarray([1,2,4,10,1,7,10,3,1,7]); # x = np.random.random(100) xi=np.linspace(min(x),

How do I link a shiny action button to a plotly animation in R?

♀尐吖头ヾ 提交于 2019-12-19 11:50:35
问题 I am trying to trigger an animation of a plotly graph with a shiny action button. The animation is done with the use of frames in plotly. However, this creates an automatic play button that triggers the animation. I don't want this button to exist and, instead, I want to trigger the animation with a shiny action button I created. I have tried, unsuccessfully, using the plotlyProxy with the plotlyProxyInvoke("animate") function. p <- plot_ly(sinusoid, x = ~time, y = ~sin, type = "scatter",

Download a dynamic plotly graph using dynamic downloadHandler() from a shiny app

巧了我就是萌 提交于 2019-12-19 11:05:38
问题 I have the shiny app below from which Im trying to download the plotly graph through downloadHandler() . The issue is that the object that Im trying to download is either a datatable or a plotly plot so I do not know how to pass it to the downloadHandler() . Note that my download button is dynamic as well because in the first case it should download a table and in the second a plot. Note that I care just for the plot here.Open the app in browser.Firstly I install: library(webshot) install

How to generate a custom color scale for plotly heatmap in R

≡放荡痞女 提交于 2019-12-19 10:28:27
问题 I would like to get a custom color scale which looks like for plotly heatmap ( plot_ly(z = data, colors = customcolors, type = "heatmap") ) palette <- colorRampPalette(c("darkblue", "blue", "lightblue1", "green","yellow", "red", "darkred")) plot(rep(1,50),col=palette(50), pch=19, cex=3, xlab = "", ylab ="", axes = F) and where the blue end represents 1 and red end represents 10^6 and plotted data would have varying values on this interval. 回答1: The code you use to generate a color palette

Change comma and thousand separator in tick labels

走远了吗. 提交于 2019-12-19 09:02:27
问题 In a chart like the one below I wan to change the thousand separator to a dot ".", but I don't know how to use the tickformat parameter in order to get it. require(plotly) p <- plot_ly(x=~c(2012,2013,2014,2015,2016), y=~c(1200000,975000,1420000,1175000,1360000), type='bar') %>% layout(yaxis = list(title="Income in €", tickformat=",d", gridcolor = "#bbb"), xaxis = list(title="Year"), margin=list(l=80)) p 回答1: As far as I know if you use tickformat , separators gets ignored. So you can either

Creating a reactive dataframe with shiny apps

无人久伴 提交于 2019-12-19 08:42:52
问题 I am trying to get this reactive to return a data frame that I can manipulate with plotly. avghour <- reactive({ result <- data.frame() start_date <- as.numeric(unlist(input$i6[1])) end_date <- as.numeric(unlist(input$i6[2])) mkw <- maxkwpeakdates[(maxkwpeakdates >= start_date & maxkwpeakdates <= end_date) & !is.na(maxkwpeakdates), ] mkw <- na.omit(mkw) mopkw <- maxonpeakkwdates[(maxonpeakkwdates >= x & maxonpeakkwdates <= y) & !is.na(maxonpeakkwdates), ] mopkw <- na.omit(mopkw) mkwhour <-