plotly

plotly_build modifies legend and labels

╄→尐↘猪︶ㄣ 提交于 2019-12-06 04:00:42
问题 I have a problem when transforming a ggplot2 graph to plotly. Here it is a reproducible code: library(ggplot2) library(plotly) # Build the data dgraf<-data.frame(num=seq(0,2*pi,length.out=100), name=sample(apply(expand.grid(letters,letters),1,function(x) paste(x,collapse="\n")),100),stringsAsFactors = F) dgraf$y<-sin(dgraf$num) rpoint<-sample(25:75,1) dgraf$ypoint<-NA dgraf$ypoint[rpoint]<-dgraf$y[rpoint] dgraf$ymin<-NA dgraf$ymin[1:rpoint]<-runif(1,0.25,0.75) dgraf$ymax<-NA dgraf$ymax[rpoint

Line hover text in Plotly

倾然丶 夕夏残阳落幕 提交于 2019-12-06 03:48:23
问题 I am plotting a graph with Plotly similar to the example on the Plotly website. Along with the hover text on the graph nodes, I want to have a hover text on the edges as well. I tried to achieve this by modifying the trace object for edges by adding a 'name' field, but this didn't work and was putting the 'name' on the nodes. trace3=Scatter( x=Xed, y=Yed, name="my_hover_text", mode='lines', line=Line(color='rgb(210,210,210)', width=1), hoverinfo='name' ) Using the 'text' field instead of the

Add Annotation to 3D Scatterplot in Plotly

核能气质少年 提交于 2019-12-06 03:31:09
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 have for 2D Analogs) and while the code compiles, the text does not show up. p <- plot_ly(all, x = X, y =

How to plot a vertical line at the x-axis range median position using plotly in Python API?

旧巷老猫 提交于 2019-12-06 03:26:27
问题 I'm trying to plot a vertical line that's dynamically positioned so that when filtering happens, the line will move accordingly. For example, with the below code, I can plot a stationary vertical line at 25K which works with the full dataset as the median, but when the data is filtered to "Americas" only since the x-axis range is now 45K, the line is not at the median position anymore. So how can I plot a vertical line that's positioned at the x-axis range's median position? Thanks import

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

偶尔善良 提交于 2019-12-06 02:27:22
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. First of all, a matrix can only hold data of one class. Hence you have a matrix of strings that you are converting to a data.frame . Because by default stringAsFactors = TRUE , your character matrix

How to change axis features in plotly?

痞子三分冷 提交于 2019-12-06 02:26:15
问题 I have the following bar in plotly and I want to : get the x-axis title away from the axis label so they dont overlap make the Y-axis labels bigger bring the bar values to the top of bars My code is : library(plotly) plot_ly(x = c('100-200','200-400', '400-600','600-800','800- 1000'), y = c(12261,29637,17469,11233,17043), name = "dd", type = "bar", xaxis = list(title ="tr"), yaxis = list(title = "cc") , text = c(12261,29637,17469,11233,17043),textposition = 'auto') %>% layout( xaxis = list

Y-axis autoscaling with x-range sliders in plotly

拟墨画扇 提交于 2019-12-06 02:13:33
问题 Afaik, y-axis cant be made to auto scale when using x-range sliders. Y range is chosen with respect to the y values of the whole x range and does not change after zooming-in. This is especially annoying with candlestick charts in volatile periods. When you zoom-in using x-range slider, you essentially get flat candlesticks as their fluctuations only cover a very small part of the initial range. After doing some research it seems that some progress has been made here: https://github.com/plotly

How to use plotly to return the same event_data information for selected points even after modifying the data

丶灬走出姿态 提交于 2019-12-06 02:09:41
问题 I'm trying to do something seemingly simple: when the user clicks on a data point or select multiple points with lasso selection, I want to draw these points in a different colour. In order to do that, I look at what points are selected, and add a col variable to the dataframe, and I tell the ggplot to colour the points according to that column. It does work for the first selection. But whenever there are already selected points, selecting the next set of points doesn't work. I've added debug

HTML widgets in Jupyter R Notebook

半城伤御伤魂 提交于 2019-12-05 23:14:50
问题 Im unable to display HTML widgets in Jupyter Notebooks when using R (works when using python). For example none of the plotly charts work in Jupyter R notebook. Is there any solution for this? library(plotly) set.seed(100) d <- diamonds[sample(nrow(diamonds), 1000), ] plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity), mode = "markers", color = carat, size = carat) The code executes but no graph is displayed 回答1: You need to make a call to embed_notebook (see the examples

plotly choropleth map: display country names

风流意气都作罢 提交于 2019-12-05 21:49:08
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, type = 'choropleth', color = GDP..BILLIONS., colors = 'Blues', marker = list(line = l), colorbar = list