plotly

R Plotly animated chart only showing groups with data in initial frame

老子叫甜甜 提交于 2019-12-11 13:47:02
问题 I'm trying to create an animated bubble chart using plotly in R, and I've run into a particularly difficult issue. library(plotly) dates <- 2000:2010 countries <- c("US", "GB", "JP") df <- merge(dates, countries, all=TRUE) names(df) <- c("Date", "Country") df$x <- rnorm(nrow(df)) df$y <- rnorm(nrow(df)) df[1:3, c("x", "y")] <- NA p <- plot_ly(df, x=~x, y=~y, color=~Country, frame=~Date, type="scatter", mode="markers") p Due to the missing values for the US' first 3 years, the resulting plot

Python: How to revolve a surface around z axis and make a 3d plot?

百般思念 提交于 2019-12-11 13:25:39
问题 I want to get 2d and 3d plots as shown below. The equation of the curve is given. How can we do so in python? I know there may be duplicates but at the time of posting I could not fine any useful posts. My initial attempt is like this: # Imports import numpy as np import matplotlib.pyplot as plt # to plot the surface rho = b*cosh(z/b) with rho^2 = r^2 + b^2 z = np.arange(-3, 3, 0.01) rho = np.cosh(z) # take constant b = 1 plt.plot(rho,z) plt.show() Some related links are following: Rotate

Plotly axis as exponential format

夙愿已清 提交于 2019-12-11 13:24:56
问题 This is a follow up on this question: SO Q The answer in the above question uses JavaScript code that turns an axis ticks into exponential. It works for a single axis on a single plot. When running it in a subplot() structure, it only works on the first plot when I apply it to the final plot. The modification I am looking for are these: 1: How to make it work on subplots. I tried calling JavaScript in the build of each subplot, but all plots came out without exponential then. 2: make it work

colorscale = “Rainbow” in plot_ly doesn't work

淺唱寂寞╮ 提交于 2019-12-11 12:58:23
问题 I am trying to plot a 3d surface by using plot_ly package. x = c(1:10) y = c(1:10) z = matrix(runif(100),ncol = 10) z_col = matrix(runif(100),ncol = 10) plot_ly(x = ~x, y = ~y, z = ~z, surfacecolor =~ z_col, type = "surface", colorscale = "Rainbow") I expect the the color for the color bar will be like this: However, this is what I get: Can anyone show me how to show this problem ? 回答1: From the documentation: colorscale (colorscale) Sets the colorscale. The colorscale must be an array

Multiple Y-axis on graph not aligned

蹲街弑〆低调 提交于 2019-12-11 12:13:33
问题 I created a graph through R's Plotly library. The graph has 2 y-axis's and everything looks fine, except that the y-axis's are misaligned. How do I "realign" it? 回答1: Python answer here Had the same issue, add rangemode = "tozero" to your overlaying axis plot_ly(data = dat, x = x, y = y, type = "bar", name = "Y") %>% add_trace(data = par, x = x, y = Z, name = "Z", yaxis = "y2") %>% layout(yaxis2 = list(overlaying = "y", side = "right", rangemode = "tozero")) 回答2: In the layout function, you

How do I add surfaces such a planes as traces generated mathematical formulas in a 3D scatter plot in plotly in r?

我只是一个虾纸丫 提交于 2019-12-11 10:46:48
问题 I'm trying to learn how to draw surfaces in a 3D scatter plot in Plotly using R. I tried to extend the example give in this questions: Add Regression Plane to 3d Scatter Plot in Plotly Except I changed the example from using a standard Iris data set to using to random clusters separated by a 2D plane with the formula: Z = -X -Y I get the error: Error in traces[[i]][[obj]] : attempt to select less than one element in get1index So I set up my data to be divided by the plane rm(list=ls())

Change axis of plotly polar plot

不问归期 提交于 2019-12-11 10:37:23
问题 I am playing with Plotly tools using python and I have made a polar plot as seen below using some dummy data: I would like to alter the axis so that the data I have (goes from around 20 to 50) is mapped to the entire 360° of the plot. Is there a way of doing this using a readymade command or do I need to write a function where you set the limits then map those numbers to degrees before changing axis labels. I have been looking through stack exchange but I can only find ways of changing it to

Grab camera position from plotly 3d graph

主宰稳场 提交于 2019-12-11 10:25:58
问题 I'm drawing plotly 3D graph and want to adjust camera position. The best way to do it for me is to use viewer, zoom and rotate scene as needed, then grab camera position as JSON and put it into my script that generate the picture to achieve the same position by default. According to this tweet, it should be working, but it doesn't. My code is: from plotly.graph_objs import Scatter3d, Layout, Scene from plotly.offline import iplot import plotly from numpy import sin, cos, linspace, pi, zeros

dash plotly - create a dropdown menu dynamically, selection of multiple rows, table export?

时光怂恿深爱的人放手 提交于 2019-12-11 10:14:21
问题 I have a data set that looks like this: cat_id author year publisher country value (dollars) name1 kunga 1998 D and D Australia 10 name2 siba 2001 D and D UK 20 name3 siba 2001 D and D US 20 name3 shevara 2001 D and D UK 10 name3 dougherty 1992 D and D Australia 20 name4 ken 2011 S and K Australia 10 I want to turn this into a table in plotly dash. I have most of the code that I want set up: #!/usr/bin/env python import dash from dash.dependencies import Input, Output, State import dash_table

Retrieve axis tick information from a plotly figure

偶尔善良 提交于 2019-12-11 09:29:22
问题 I'm plotting a heatmap using R plotly : set.seed(1) df <- reshape2::melt(matrix(rnorm(100*20),100,20,dimnames = list(paste0("G",1:100),paste0("S",1:20)))) library(plotly) library(dplyr) plot_ly(z=c(df$value),x=df$Var2,y=df$Var1,colors=grDevices::colorRamp(c("darkblue","gray","darkred")),type="heatmap",colorbar=list(title="Scaled Value",len=0.4)) %>% layout(yaxis=list(title=NULL),xaxis=list(tickangle=90,tickvals=10,ticktext="X-Label")) As you can see, plotly is not showing all y-axis ticks. My