plotly

How to show all legend in conditional plot and show several legends in plotly

只愿长相守 提交于 2021-01-29 08:29:13
问题 I am trying to make a plot similar to the next one: While I have until now is: Which is generated with the following code: import plotly.io as pio pio.renderers.default='browser' import plotly.graph_objects as go import pandas as pd import numpy as np input_df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv') threshold =2.8 name_yaxis="Gap" input_df["AAPL.High"] = (input_df["AAPL.High"]-min(input_df["AAPL.High"]))*(threshold)/(max(input_df[

Make subplots of plot_ly graph in R

心已入冬 提交于 2021-01-29 07:10:17
问题 I have a dataframe, which can be created in this way: x = data.frame(metrics=c("type1", "type1", "type1", "orders", "orders", "orders", "mean","mean","mean"), hr=c(6,7,8,6,7,8,6,7,8), actual=c(14,20,34,56,12,34,56,78,89)) I tried to draw a scatterplot using plot_ly function. I wrote a function for it (i need it to be a function): plot <- function(df){ gp <- df %>% plot_ly( x = ~ hr, y = ~ actual, group = ~ metrics, hoverinfo = "text", hovertemplate = paste( "<b>%{text}</b><br>", "%{xaxis

Colorbar is overlapping with Contour Plot in Plotly

﹥>﹥吖頭↗ 提交于 2021-01-29 06:50:55
问题 I am getting margin on the left and right of the first subplot (please look at the image I have included at the end of the post) of the contour which I do no understand. Moreover, I can not position correctly the colorbar in the second plot. How can I fix the code? def bern(theta, z, N): """Bernoulli likelihood with N trials and z successes.""" return np.clip(theta**z * (1-theta)**(N-z), 0, 1) def bern2(theta1, theta2, z1, z2, N1, N2): """Bernoulli likelihood with N trials and z successes."""

Add a permanent contour line to a surface plot in R plotly

走远了吗. 提交于 2021-01-29 06:36:28
问题 I am using the plotly package in R to draw a surface plot and a contour plot: # Load package library(plotly) # Simulate the data for plotting x <- y <- seq(from = 0, to = 100, by = 1) z1 <- outer(X = x, Y = y, FUN = function(x, y) x^0.2 * y^0.3) # data for surface plot # Draw surface plot (3D) plotly::plot_ly(z = z1) %>% plotly::add_surface( contours = list( z = list( show = TRUE, usecolormap = TRUE, highlightcolor = "#ff0000", project = list(z = TRUE) ) ) ) # Draw contour plot (2D) plot_ly(z

How can I get all Plotly plots created inside a for loop display in single browser window?

被刻印的时光 ゝ 提交于 2021-01-29 05:46:06
问题 I am trying to create several plots inside a for loop using plotly. Currently all the charts appear in separate tabs of browser. I want all the charts to appear in the same browser window. In my data frame df, for each unique element in Tool_MeasurementSet column (unique elements saved as a list meas_set) has 16 data points for X-BAR and 16 for SIGMA. I was able to use subplot function to combine X-BAR and SIGMA plot for each element in meas_set. Currently the code is creating plots for each

How to properly handle datetime and categorical axes in bokeh/holoviews heatmap plot?

☆樱花仙子☆ 提交于 2021-01-29 04:48:59
问题 I'm trying to plot a simple heatmap using bokeh/holoviews. My data (pandas dataframe) has categoricals (on y) and datetime (on x). The problem is that the number of categorical elements is >3000 and the resulting plot appears with messed overlapped tickers on the y axis that makes it totally useless. Currently, is there a reliable way in bokeh to select only a subset of the tickers based on the zoom level? I've already tried plotly and the result looks perfect but however I need to use bokeh

How to add a horizontal scrollbar to the X axis?

蹲街弑〆低调 提交于 2021-01-29 03:51:46
问题 I want to add a (horizontal) scrollbar to the X axis, because the number of points is large. How can I do it? trace0 = go.Scatter( x = x1_values, y = y1_values, name = "V1" ) data = [trace0] layout = dict(title = title, xaxis = dict(tickmode='linear', tickfont=dict(size=10)), yaxis = dict(title = "Title") ) fig = dict(data=data, layout=layout) iplot(fig) 回答1: Using plotly you can add a rangeslider using fig['layout']['xaxis']['rangeslider'] with functionality that exceeds that of a scrollbar:

Plotly: How to add trendline and parallel lines to time series data?

丶灬走出姿态 提交于 2021-01-28 21:54:11
问题 My goal is to add 5 fit lines to the exchange index, which is a time series data. Below is what I want to achieve: There should be a plotted (&log2 transformed) index, a best fit line (in yellow), and 4 other parallel lines where it covers 95%, 75%, 25% and 5% of the index respectively. The x-axis is omitted in the picture, but it should be dates. So my question is how to add these 5 lines using Plotly? With my current code, I was able to plot the index without the 5 parallel lines but I

Plotly: How to add trendline and parallel lines to time series data?

二次信任 提交于 2021-01-28 21:41:33
问题 My goal is to add 5 fit lines to the exchange index, which is a time series data. Below is what I want to achieve: There should be a plotted (&log2 transformed) index, a best fit line (in yellow), and 4 other parallel lines where it covers 95%, 75%, 25% and 5% of the index respectively. The x-axis is omitted in the picture, but it should be dates. So my question is how to add these 5 lines using Plotly? With my current code, I was able to plot the index without the 5 parallel lines but I

Using alpha and manual colours with ggplotly

只谈情不闲聊 提交于 2021-01-28 20:14:39
问题 I am having difficulty setting manual colours with ggplotly . library(ggplot2) library(plotly) set.seed(1) data.frame(x = 1:10, y = rnorm(10)) %>% ggplot(aes(x, y, fill = factor(x > 5), alpha = y)) + geom_bar(stat = "identity") + scale_fill_manual(values = c("red", "blue")) ggplotly() I get the error: Error in setNames(as.numeric(x), c("red", "green", "blue", "alpha")) : 'names' attribute [4] must be the same length as the vector [1] with traceback: 14: setNames(as.numeric(x), c("red", "green