plotly

How to create two y-axes streaming plotly

一个人想着一个人 提交于 2019-12-04 20:44:39
I followed the plotly examples to successfully create a streaming temperature graph using my DHT22 sensor. The sensor also provides humidity which I would like to plot as well. Is it possible somehow? The following code is what I'm trying but an exception is thrown: plotly.exceptions.PlotlyAccountError: Uh oh, an error occured on the server. no data is being plot to the graph (see bellow). with open('./plotly.conf') as config_file: plotly_user_config = json.load(config_file) py.sign_in(plotly_user_config["plotly_username"], plotly_user_config["plotly_api_key"]) streamObj = Stream(token=plotly

How to format data for plotly sunburst diagram

浪子不回头ぞ 提交于 2019-12-04 20:23:44
I'm trying to make an sunburst diagram using Plotly via R. I'm struggling with the data model required for the hierarchy, both in terms of conceptualizing how it works, and seeing if there are any easy ways to transform a regular dataframe, with columns representing different hierarchical levels, into the format needed. I've looked at examples for plotly sunburst charts in R, e.g., here , and seen the reference page but don't totally get the model for data formatting. # Create some fake data - say ownership and land use data with acreage df <- data.frame(ownership=c(rep("private", 3), rep(

plotly rangeslider how to determine if range is selected

☆樱花仙子☆ 提交于 2019-12-04 19:56:32
Needs to know when dragging on a rangeslider is done. Adding an event on the sliderDiv on 'dragend' only yields occasional notification. Listening on the plotly_relayout gives too many events. I think an event like "plotly_rangeslider_dragend" is not supported yet. So you must use a workaround. To determine a rangeslider event you can use "plotly_relayout" and look into the eventdata-Object like the code below: var timer=undefined; var plotlyRelayoutEventFunction=function(eventdata){ if( Object.prototype.toString.call(eventdata["xaxis.range"]) === '[object Array]' ) { console.log("rangeslider

Disable mouse click to show another slide in rmarkdown slidy_presentation

女生的网名这么多〃 提交于 2019-12-04 19:36:09
I'm wondering how to disable left mouse click to show another slide in rmarkdown slidy_presentation. If I'm trying to disable/enable some category in plotly chart, it'll skip to another slide. Is there any option how to handle it. Many thanks for your suggestions in forward. rasnes In my current version of slidy (rmarkdown 1.6) you can disable/enable mouse click advance by pressing key 'k' , when viewing the presentation. To change the default (on file open) behavior I had to change line 55 in [R package library]/rmarkdown/rmd/slidy/Slidy2/scripts/slidy.js to mouse_click_enabled: false, //

Interactively adding points to plotly R without redrawing background plot

心不动则不痛 提交于 2019-12-04 19:02:26
The MWE below oversimplifies my real goal. However, I have a background image that takes a long time to draw (in the example below it is simply a scatterplot of 32 mtcars dataset values). Users can click on certain points from my background image, and this will cause new points to be plotted. My aim is for these new points to simply be redrawn on the top layer, while the background image scatterplot does not need to be redrawn to save time and computation. My MWE is as follows: library(plotly) library(htmlwidgets) g <- ggplot(mtcars, aes(x=mpg, y=cyl)) + geom_point() gP <- ggplotly(g) gP %>%

how to give more space to ticks labels in R plotly

喜夏-厌秋 提交于 2019-12-04 18:14:27
I have an horizontal bar diagram in r plotly, and I would like to give ticks labels more space. See the example below : libelle <- c("financial activities","Agriculture, sylviculture and fishing","Manufacture of transport materials","financial activities","Agriculture, sylviculture and fishing","Manufacture of transport materials") value <- c(15000000,987000,154000000,10000000,927000,15400000) annee <- c("2011","2011","2011","2012","2012","2012") data <- data.frame(libelle,value,annee) plot_ly(data=data,x=value,y=libelle,group=annee,type="bar",orientation="h") I can't see the labels on the

Add custom data label in ggplotly scatterplot

♀尐吖头ヾ 提交于 2019-12-04 17:41:19
I would like to display the Species for each data point when the cursor is over the point rather than the than the x and y values. I use the iris dataset. Also I want to be able to click on a data point to make the label persistent and not get disapperaed when I choose a new spot in the plot. (if possible ). The basic is the label. The persistence issue is a plus. Here is my app: ## Note: extrafont is a bit finnicky on Windows, ## so be sure to execute the code in the order ## provided, or else ggplot won't find the font # Use this to acquire additional fonts not found in R install.packages(

How to write a text into plotly heat map in r?

别说谁变了你拦得住时间么 提交于 2019-12-04 16:56:00
Hello I make a heat map with plotly . The code is: plot_ly(z = ~df$MonetaryClass, x = ~df$RecencyClass, y = ~df$FrequencyClass, type = "heatmap") %>% colorbar(title = 'Monetary Class', limits = c(1,5), tickmode = 'array', tickvals = c(1,2,3,4,5)) %>% layout(title = "RFM Analyse", xaxis = list(title = 'Recency Class', tickmode = 'array', tickvals = c(1, 2,3,4,5), ticktext = c(1, 2, 3, 4, 5) ), yaxis = list(title = 'Frequency Class', tickmode = 'array', tickvals = c(1, 2,3,4,5), ticktext = c(1, 2, 3, 4, 5) ) ) Here is a sample of 100 of my data frame, and the information of dput() : structure

Generate list of R plotly plots and pass it to subplot

感情迁移 提交于 2019-12-04 15:32:47
I usually generate subplots in a for loop when using base R graphics (using par(mfrow=c(nr,nc)) ). I'm trying to do something similar with plotly , by generating a series of plots and saving them to a list to be later passed to the subplot function. However, for reasons that I don't understand, at the end of the loop all the elements of the list seem to contain the same plot (the last one). If I print each plot in the list within the loop (uncommenting the line starting with print in the example below), then the plots seem fine). I don't really understand what's going on. Could someone explain

Add plotly traces dynamically on shiny

北城以北 提交于 2019-12-04 14:57:47
I am building an app that allows a user to dynamically add and remove traces on a plotly graph using selectInput. I have tried to play around with plotlyProxy () and plotlyProxyInvoke () from plotly package to no avail. Below is my rudimental code : library(shiny) library(shinydashboard) library(plotly) ui <- dashboardPage( dashboardHeader(), dashboardSidebar( sidebarMenu( menuItem("Search", tabName = "Tabs", icon = icon("object-ungroup")) ) ), dashboardBody( tabItem(tabName = "Tabs", fluidRow( column(width=3, box( title="SELECT ", solidHeader=TRUE, collapsible=TRUE, width=NULL, selectInput(