plotly

Placing donut charts side by side using plotly in R

谁说胖子不能爱 提交于 2021-02-08 10:40:52
问题 I have created donut charts from plotly from the following: library(plotly) library(RColorBrewer) test<-data_frame(Score=c("Green","Green","Yellow","Yellow","Clear","Clear","Red","Red"),Lang=c(rep("Eng",4),rep("Esp",4))) test1<-data_frame(Score=c("Green","Yellow","Yellow","Yellow","Clear","Clear","Red","Red"),Lang=c(rep("Eng",4),rep("Esp",4))) color_order<-c("Green","Clear","Yellow","Red") colors<-c("#31a354","#bdbdbd","#fec44f","#de2d26") a<-test %>% mutate(Score=factor(Score,levels=color

facet labels in plotly

徘徊边缘 提交于 2021-02-08 10:40:15
问题 I'd like to change the facet labels in a plotly(_express) plot. Here's the plot: import plotly.express as px tips = px.data.tips() fig = px.scatter(tips, x="total_bill", y="tip", color="smoker", facet_col="sex") fig.show() What I'd like is to remove the sex= from the labels. 回答1: UPDATE: as of plotly version 4.2 in October 2019, the following usage of for_each_annotation is recommended by the docs at https://plotly.com/python/facet-plots/#customize-subplot-figure-titles import plotly.express

Placing donut charts side by side using plotly in R

不羁岁月 提交于 2021-02-08 10:39:05
问题 I have created donut charts from plotly from the following: library(plotly) library(RColorBrewer) test<-data_frame(Score=c("Green","Green","Yellow","Yellow","Clear","Clear","Red","Red"),Lang=c(rep("Eng",4),rep("Esp",4))) test1<-data_frame(Score=c("Green","Yellow","Yellow","Yellow","Clear","Clear","Red","Red"),Lang=c(rep("Eng",4),rep("Esp",4))) color_order<-c("Green","Clear","Yellow","Red") colors<-c("#31a354","#bdbdbd","#fec44f","#de2d26") a<-test %>% mutate(Score=factor(Score,levels=color

Huge proglem to load Plotly plots in Jupyter Notebook Python

放肆的年华 提交于 2021-02-08 10:37:23
问题 I have a huge problem with Jupyter Notebook. When he builds graphs using the plot packet, to display the next graph I have to reload the dataset, otherwise an error pops up: TypeError: list indices must be integers or slices , not str. When I reopen the project, all the graphs created using Plotly are not visible, just a white background and I have to reload them if I want to see them, and everything after reloading the dataset, that is: 1) I open the project in Jupyte Notebook, all graphs

Huge proglem to load Plotly plots in Jupyter Notebook Python

我与影子孤独终老i 提交于 2021-02-08 10:37:20
问题 I have a huge problem with Jupyter Notebook. When he builds graphs using the plot packet, to display the next graph I have to reload the dataset, otherwise an error pops up: TypeError: list indices must be integers or slices , not str. When I reopen the project, all the graphs created using Plotly are not visible, just a white background and I have to reload them if I want to see them, and everything after reloading the dataset, that is: 1) I open the project in Jupyte Notebook, all graphs

Plotting multiple pie charts in plotly

非 Y 不嫁゛ 提交于 2021-02-08 10:27:19
问题 I have the following code from edited from: How to plot pie charts as subplots with custom size with Plotly in Python import plotly import plotly.offline as py import plotly.graph_objs as go py.init_notebook_mode(connected=True) labels = ['Oxygen','Hydrogen','Carbon_Dioxide','Nitrogen'] values = [4500,2500,1053,500] domains = [ {'x': [0.0, 0.33], 'y': [0.0, 0.50]}, {'x': [0.33, 0.66], 'y': [0.0, 0.50]}, {'x': [0.66, 1], 'y': [0.0, 0.50]}, {'x': [0.0, 0.33], 'y': [0.50, 1]}, {'x': [0.33, 0.66]

How to add arrows below the original axis in plotly 2D scatter plot

梦想与她 提交于 2021-02-08 10:04:34
问题 Creating 2D scatter plot by plotly can be done following the example from: https://plot.ly/python/line-and-scatter/ However, is there any easy way to add arrows below the x axis? 回答1: You could use Plotly's annotations without text. import plotly import numpy as np plotly.offline.init_notebook_mode() N = 1000 data = [plotly.graph_objs.Scatter(x=np.random.randn(N), y=np.random.randn(N), mode = 'markers' ) ] xstart = -2 xmax = 3.5 xmin = -3.5 padding = 0.05 ypos = -0.1 layout = plotly.graph

How to add arrows below the original axis in plotly 2D scatter plot

荒凉一梦 提交于 2021-02-08 10:02:07
问题 Creating 2D scatter plot by plotly can be done following the example from: https://plot.ly/python/line-and-scatter/ However, is there any easy way to add arrows below the x axis? 回答1: You could use Plotly's annotations without text. import plotly import numpy as np plotly.offline.init_notebook_mode() N = 1000 data = [plotly.graph_objs.Scatter(x=np.random.randn(N), y=np.random.randn(N), mode = 'markers' ) ] xstart = -2 xmax = 3.5 xmin = -3.5 padding = 0.05 ypos = -0.1 layout = plotly.graph

Plotly: How to set node positions in a Sankey Diagram?

时间秒杀一切 提交于 2021-02-08 08:48:22
问题 The sample data is as follows: unique_list = ['home0', 'page_a0', 'page_b0', 'page_a1', 'page_b1', 'page_c1', 'page_b2', 'page_a2', 'page_c2', 'page_c3'] sources = [0, 0, 1, 2, 2, 3, 3, 4, 4, 7, 6] targets = [3, 4, 4, 3, 5, 6, 8, 7, 8, 9, 9] values = [2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2] Using the sample code from the documentation fig = go.Figure(data=[go.Sankey( node = dict( pad = 15, thickness = 20, line = dict(color = "black", width = 0.5), label = unique_list, color = "blue" ), link = dict(

R Plotly Add Trace within Loop

时光毁灭记忆、已成空白 提交于 2021-02-08 08:13:26
问题 I have an issue with using loops to add trace in plotly, though I have no idea what the cause is. If I try to make a plot using the method for P below, only the data for last column (HORSE) is shown. Rabbit and Dog still show up, but both display values for Horse. If, however, I use the P1 method the graph works perfectly. I would really like to be able to do this within a loop as the length of columns varies. df <- data.frame(AGE = c(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3