plotly

Plotly: How to add multiple y-axes?

旧巷老猫 提交于 2021-01-28 01:30:54
问题 I have data with 5 different columns and their value varies from each other. Actual gen Storage Solar Gen Total Gen Frequency 1464 1838 1804 18266 51 2330 2262 518 4900 51 2195 923 919 8732 49 2036 1249 1316 3438 48 2910 534 1212 4271 47 857 2452 1272 6466 50 2331 990 2729 14083 51 2604 767 2730 19037 47 993 2606 705 17314 51 2542 213 548 10584 52 2030 942 304 11578 52 562 414 2870 840 52 1111 1323 337 19612 49 1863 2498 1992 18941 48 1575 2262 1576 3322 48 1223 657 661 10292 47 1850 1920

Shiny error while using nearPoints in renderPlotly click event

早过忘川 提交于 2021-01-27 21:11:24
问题 I would like to fetch nearPoints using the data from a click event. I have found the below snippet from the Shiny webpage and it works fine as expected. output$plot <- renderPlot({ d <- data() plot(d$speed, d$dist) }) output$plot_clickedpoints <- renderPrint({ # For base graphics, we need to specify columns, though for ggplot2, # it's usually not necessary. res <- nearPoints(data(), input$plot_click, "speed", "dist") if (nrow(res) == 0) return() res }) I tried to mimic the above the approach

Ggplotly with tooltip has problems using geom_rect()

有些话、适合烂在心里 提交于 2021-01-27 20:05:23
问题 I am trying to plot some data in a ggplotly plot. The x-axis contains dates. Ggplotly doesn't work well with dates as when I hover over a point, the date is displayed as a number. I solved this by setting a tooltip like below. Some sample data: x <- data.frame(Date = as.Date(seq(Sys.Date(), Sys.Date() + 29, by = "days")), Amount = seq(-10000, 19000, by = 1000), stringsAsFactors = FALSE) The plot: ggplotly(ggplot(x, aes(x = Date, y = Amount, group = 1, text = paste("Date: ", Date, "<br>Amount:

How to display ggplotly plots with dynamically created tabs and for-loops?

可紊 提交于 2021-01-27 20:03:27
问题 I have R markdown document and I want to dynamically create tabs with ggplotly graphics inside them --- output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r} library(ggplot2) library(plotly) ``` ```{r} fig=ggplot(cars)+geom_point(aes(speed, dist)) ``` # level 1 ## level 2{.tabset .tabset-pills} ```{r echo=FALSE, results='asis'} for (h in 1:3){ cat("###", h,'{-}', '\n\n') ggplotly(fig) cat( '\n\n') } ``` I understand that it is different from

Plotly: Change order of elements in Sunburst Chart

旧时模样 提交于 2021-01-27 19:30:40
问题 I am currently using plotly express to create a Sunburst Chart. However, i realized that children are ordered alphabetical for nominal values. Especially for plotting months that is pretty unlucky... Do you know how to handle that issue? Maybe a property or some workaround? Below there is an example so you can try it yourself. Thanks in advance! import plotly.express as px import pandas as pd import calendar months = [x for x in calendar.month_name if x] #Create Dataframe data = [] for m in

R Plotly overlay bar chart

守給你的承諾、 提交于 2021-01-27 18:01:55
问题 Question in short: using R and the Plotly package, can I create an overlay bar chart where 2 series are shown using the same position on the x-axis? After quite a bit of Googling, I could not find the answer. For example this visualisation: Code to create a grouped (not-overlayed) stacked bar, using Plotly and R: months = 1:12 n1 = runif(12, min = 0, max = 1) n2 = runif(12, min = 0, max = 1) dfPlot = data.frame(months, n1, n2) plot_ly(x = dfPlot [,1], y = dfPlot [,2], type = 'bar') %>% add

How can I customize the modebar in plotly (preferably in R)?

孤街醉人 提交于 2021-01-27 12:10:21
问题 In particular, I am looking for a way to hide all buttons except the download image button. I tried to use the config argument but so far only managed to hide the entire modebar using displayModeBar = F . Any help would be highly appreciated. 回答1: Here's what you are looking for: plot_ly(economics, x = ~pop) %>% config(displaylogo = FALSE, collaborate = FALSE, modeBarButtonsToRemove = c( 'sendDataToCloud', 'autoScale2d', 'resetScale2d', 'toggleSpikelines', 'hoverClosestCartesian',

Is there a way to change origin axis (zeroline) on scatter graph?

流过昼夜 提交于 2021-01-27 11:15:32
问题 Is there a way to change axes on scatter graph? let's say move the axis from (0,0) i.e (zero-line) to something like (3,3) and make a quadrant graph I've tried setting the "zeroline" value on both "xaxis" and "yaxis" to False and then drawing two constant lines across both the axes from 'shapes'. But I'd want to know if there's any way to change the origin axes. Here's the example in the image import plotly.graph_objs as go import plotly import plotly.io as pio trace0 = go.Scatter( x=[7], y=

Plotly displaying sad 'fail' face instead of output

*爱你&永不变心* 提交于 2021-01-27 06:00:48
问题 I'm using plotly==4.5.1 in a jupyter==1.0.0 notebook, python==3.7.4 . The same piece of code which previous showed this: Is now showing this, without having had any modifications: Does anyone have any insights over why this might be? Is it something to do with plotly's online/offline modes? For completeness, here is some example dummy data df_heat = pd.DataFrame({'lat': {0: -62.884215, 1: -62.834226, 2: -62.811707, 3: -62.744564, 4: -62.704835}, 'lon': {0: 39.4402361, 1: 39.4080722, 2: 39

Using numerical values in plotly for creating Gantt-Charts

不打扰是莪最后的温柔 提交于 2021-01-27 05:33:16
问题 I want to create interactive Gantt-Charts (or a sequence chart) for displaying the scheduling of tasks on multiple processors. I found the library plotly, which produced very good and interactive Gantt-charts. Unfortunately, plotly-Gantt only works with dates and not numerical values, like I have with the runtime values of the schedule. Is there a possibility to create Gantt-charts in plotly with numerical values? Code Example: (I would like to use something like this) import plotly.figure