plotly

manually set colors per group in barplot ggplot

一笑奈何 提交于 2019-12-07 17:23:06
问题 I need to manually set colors for each group in a barplot. I currently have the fill = time and this is currently determining the colors. We have 5 brands and the values for 2 separate months per brand. I need to group by brand but also need a way to display which bar represents which month(time), I can currently do this however I want to color each bar group. eg. brand1 bars = red, brand2 bars = blue ect whilst still having fill = time Here is my code: colors <- c("#98999B", "#F4C400", "

Launch Dash from Jupyter Notebook

纵饮孤独 提交于 2019-12-07 17:02:29
Is there a way I can launch a Dash dahsboard using the below line of code in Jupyter notebook? # if __name__ == '__main__': # app.run_server(debug=True) When I try to launch this I get an error. The only way to correct it is to set debug to false. But then the Dashboard does not update automatically when the data feeding the charts is altered. EDIT I just found out that a valuable GitHub user published the following library . This is the direct link to the respective repo . See his documentation and examples to implement it successfully within jupyter. It worked for me. DON'T understimate this

SVG to PDF conversion working for Plotly.js but not for C3.js

◇◆丶佛笑我妖孽 提交于 2019-12-07 16:47:20
问题 I am using css2pdf for saving my svg chart to pdf after onclick event. It works nicely for plotly.js, but not for c3.js - please see my fiddle: http://jsfiddle.net/3hs7cs4f/ I am sure it has to do something with the c3.js svg properties, but I have no idea how to solve this. Here is the code: <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" rel="stylesheet" /> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <script src="http://www.cloudformatter.com

Error with embed_notebook, getting plotly to work on Jupyter

和自甴很熟 提交于 2019-12-07 16:39:20
问题 I am trying to have embedded R plotly charts in Jupyter I am following https://plot.ly/r/using-r-in-jupyter-notebooks/ But stuck at "Make sure that both pandoc.exe and pandoc-citeproc are available in your local python installation folder (or Jupyter environment if you have setup a separate environment)." I found the pandoc.exe and pandoc-citeproc. But not sure on where to copy those files. Based on the Anaconda Prompt my environment is C:\Users\myname\AppData\Local\Continuum\Anaconda2\ But

Python Plotly Sankey Graph not showing up

爱⌒轻易说出口 提交于 2019-12-07 15:12:26
Was wondering if anyone can help figure out why this Sankey diagram is not working. I am pretty sure I followed the proper syntax and conventions to use the module. Been banging my head on the table because of this. import plotly.offline data_trace = {'domain': {'x': [0, 1], 'y': [0, 1]}, 'height': 772, 'link': {'label': ['EM', 'GWF9C51E', 'GWF9C511', 'GWF9C51E Sensor Set', 'GWF9C511 Sensor Set'], 'source': [0, 1, 3, 1, 4, 2, 0, 2], 'target': [1, 3, 1, 0, 2, 0, 2, 4], 'value': [40, 76, 29, 86, 30, 75, 41, 65]}, 'node': {'color': ['blue', 'yellow', 'yellow', 'green', 'green'], 'label': ['EM',

Plot.ly in R: Unwanted alphabetical sorting of x-axis

烂漫一生 提交于 2019-12-07 15:08:25
问题 I tried for hours, but I could not succeed. My data frame is simply df <- as.data.frame(matrix(c("g","d","a","b","z",5,4,3,2,1),5,2)) library("plotly") p <- plot_ly(data = df,x = ~V1,y = ~V2,type = "scatter",mode = "lines+markers") %>% layout(title = "my title") p So, this give me But I don't want x axis to be sorted alphabetically, I just want to keep the order as it is and see a decreasing graph. 回答1: First of all, a matrix can only hold data of one class. Hence you have a matrix of strings

plotly choropleth map: display country names

自古美人都是妖i 提交于 2019-12-07 13:00:35
问题 Consider the following R code to produce a choropleth map in plotly: #devtools::install_github("ropensci/plotly") library(plotly) df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv') # light grey boundaries l <- list(color = toRGB("grey"), width = 0.5) # specify map projection/options g <- list( showframe = FALSE, showcoastlines = FALSE, projection = list(type = 'Mercator') ) plot_ly(df, z = GDP..BILLIONS., text = COUNTRY, locations = CODE,

Add Annotation to 3D Scatterplot in Plotly

假装没事ソ 提交于 2019-12-07 12:45:00
问题 I'm new to this arena and was hoping to get some help. I'm just starting to work with Plotly and am using it to build a very basic 3D Scatterplot that models some shelves and what items are where. While I built the "shelf" and the plot renders, I would like to add an Annotation to the text indicating which set of shelves I'm looking at. Here is the current output of my program and this is what I am trying to do I've tried reviewing the documentation and attempted to add an annotation (as I

Keep aspect ratio when using ggplotly

て烟熏妆下的殇ゞ 提交于 2019-12-07 10:38:46
问题 I have a ggplot hexbin chart that I want to show with ggplotly. However, when I use the ggplotly function the aspect ratio, previously fixed for the gplot chart, is lost. Minimal working example: library(ggplot2) library(plotly) library(RColorBrewer) set.seed(11) df<-data.frame(xvar=rnorm(1000,0,4),yvar=rnorm(1000)) #nicer colours palette <- colorRampPalette(rev(brewer.pal(11,'Spectral'))) colours<-palette(32) p1<-ggplot(df,aes(x=xvar,y=yvar))+ coord_fixed(ratio=1)+ stat_binhex(bins=50)+scale

Plotly: How to make stacked bar chart from single trace?

无人久伴 提交于 2019-12-07 10:31:23
问题 Is it possible to have two stacked bar charts side by side each of them coming from a single column? Here's my df: Field Issue Police Budget cuts Research Budget cuts Police Time consuming Banking Lack of support Healthcare Lack of support Research Bureaucracy Healthcare Bureaucracy Banking Budget cuts I want a stacked bar chart of Field next to a stacked bar chart of issues by field. Thanks guys! 回答1: For an example on how to make a stacked bar chart with the specific dataset provided, take