plotly

How can I plotly a ggplot treemap?

自作多情 提交于 2020-06-26 22:31:52
问题 I am looking to get this gradient colors on the map: ramp <- colorRamp(c("royalblue4", "white")) ramp.list <- rgb( ramp(seq(0, 1, length = 15)), max = 255) But also, and more important, I am looking to add plotly charactheristics to the graph (specially hovering text output). This is my data: structure(list(V1 = structure(c(9L, 8L, 4L, 7L, 2L, 6L, 1L, 3L, 5L, 10L, 13L, 11L, 12L), .Label = c("Apple", "Avocado", "Banana", "Carrot", "Mango", "Mushroom", "Onion", "Orange", "Pineapple",

Plotly: Add line to bar chart

為{幸葍}努か 提交于 2020-06-26 14:36:30
问题 I have a plotly bar chart, from a dataframe: fig = df.iplot(asFigure=True, kind='bar', barmode = 'relative') py.iplot(fig) Is it possible to turn one of the columns in the data frame into a line series? 回答1: The suggested link in the comments does have some valuable resources, but they won't answer your questions directly. iplot() uses a pandas dataframe as input, and produces a stacked barplot. Here's an approach that will let you do exactly that, albeit without using df.iplot() First, the

How to plot a nested pie chart using plotly in R?

岁酱吖の 提交于 2020-06-26 05:34:39
问题 I am trying to plot a nested pie chart, but the output didn't reflect the reality. Let's say: library('plotly') library('dplyr') data <- data.frame(c('cat', 'dog', 'deer','chicken', 'cat', 'dog','duck', 'monkey', 'fish','cow','horse','dog'),c('US', 'US', 'US','US', 'UK', 'UK','UK', 'UK','China','China','China','China'),c(15,70,120,55,47,300,89,62,40,27,103,8)) colnames(data) <- c('animal', 'country', 'total_num') p <- plot_ly(data) %>% add_pie(labels = ~animal, values = ~total_num, type =

How to plot a nested pie chart using plotly in R?

一世执手 提交于 2020-06-26 05:33:29
问题 I am trying to plot a nested pie chart, but the output didn't reflect the reality. Let's say: library('plotly') library('dplyr') data <- data.frame(c('cat', 'dog', 'deer','chicken', 'cat', 'dog','duck', 'monkey', 'fish','cow','horse','dog'),c('US', 'US', 'US','US', 'UK', 'UK','UK', 'UK','China','China','China','China'),c(15,70,120,55,47,300,89,62,40,27,103,8)) colnames(data) <- c('animal', 'country', 'total_num') p <- plot_ly(data) %>% add_pie(labels = ~animal, values = ~total_num, type =

Use Pandas index in Plotly Express

半腔热情 提交于 2020-06-25 08:39:29
问题 Plotly Express allows me to easily plot a pandas dataframe, as explained in their examples. Rather than using a named column for x and a named column for y, I would like to use the dataframe's index for x and a named column for y. Example using named columns import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length") fig.show() What i want (bogus example) import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="index", y=

How to plot annotated heatmap on plotly?

穿精又带淫゛_ 提交于 2020-06-25 06:03:20
问题 I'm trying to make a annotated heatmap on plotly. import plotly.plotly as py import plotly.tools as tls from plotly.graph_objs import * import numpy as np import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv('masterc.csv') locations = {} anno = [] for i in range(df.shape[0]): locations.setdefault((df.iat[i,2],df.iat[i,6]),0) locations[(df.iat[i,2],df.iat[i,6])]+=df.iat[i,8] x1 = [] y1 = [] z1 = [] z1_text = [] for key in locations.keys(): if key[0] not in x1: x1 += [key[0],]

Plotly sunburst plot not showing in Jupyter notebook

橙三吉。 提交于 2020-06-25 05:40:41
问题 I am using Plotly and Jupyter to generate some visuals to better understand user journeys online. I am using the Plotly sunburst chart since this makes a great visual for that purpose. Plotly provides an example that works great and provides the visual that I am looking to produce with my own data. I have created a dataframe that mirrors the example but when I try to use .show() no chart is produced. It appears to run fine (no errors) and produces white space where the chart should be but not

Hover image in plotly r chart in shiny app

丶灬走出姿态 提交于 2020-06-24 12:40:38
问题 Does anyone here have an example of showing an image when hovered on a plot or any package which can do this? I have tried something but it will show url only but not the image.I know this code is just encasing the URL. How can I build a div to show the image. library(shiny) library(shinydashboard) library(DT) library(dplyr) library(plotly) # Data ------------------------------------------------------------------ dt <- data.frame(fruits = c("apple","banana","oranges"), rank = c(11, 22, 33),

Plot multiple legends in R-plotly

旧巷老猫 提交于 2020-06-23 11:16:00
问题 I have 5 continuous variables that I'd like to graph together in R plotly. I wrote the following code and got the plot to run as expected, but I cannot figure out how to deal with the legends. As is, the color legend appears, but the size legend does not. I would like to plot both legends and control their locations within the plot. Suggestions from a similar post Adding color and bubble size legend in R plotly do not solve the problem. Here's the code and sample data: x<-sample(30) y<-sample

Plot multiple legends in R-plotly

只谈情不闲聊 提交于 2020-06-23 11:14:34
问题 I have 5 continuous variables that I'd like to graph together in R plotly. I wrote the following code and got the plot to run as expected, but I cannot figure out how to deal with the legends. As is, the color legend appears, but the size legend does not. I would like to plot both legends and control their locations within the plot. Suggestions from a similar post Adding color and bubble size legend in R plotly do not solve the problem. Here's the code and sample data: x<-sample(30) y<-sample