plotly

Individually labeled bars for bar graph in Plotly

纵然是瞬间 提交于 2019-12-03 15:46:42
I was trying to create annotations for grouped bar charts - where each bar has a specific data label that shows the value of that bar and is located above the centre of the bar. I tried a simple modification of the examples in tutorial to achieve this, as follows: import plotly.plotly as py import plotly.graph_objs as go x = ['Product A', 'Product B', 'Product C'] y1 = [20, 14, 23] y2 = [12, 18, 29] annotations1 = [dict( x=xi, y=yi, text=str(yi), xanchor='auto', yanchor='bottom', showarrow=False, ) for xi, yi in zip(x, y1)] annotations2 = [dict( x=xi, y=yi, text=str(yi), xanchor='auto',

How to customize hover text for plotly boxplots in R

我怕爱的太早我们不能终老 提交于 2019-12-03 14:56:10
I understand how to customize the hover text for scatter plots in plotly , but box plots do not accept the 'text' attribute. Warning message: 'box' objects don't have these attributes: 'text' . I have over 300 x-axis variables and there are numbered samples(1-50) in two groups(A or B) that I want to plot together in the same box plot, then I'd like to differentiate between the sample numbers and groups through hover text when moving the cursor over outliers. I'd like to have my custom data labels instead of the automatic quartile labels. Is that possible with plotly boxplots? library(plotly)

Mixing surface and scatterplot in a single 3D plot

倖福魔咒の 提交于 2019-12-03 14:09:12
问题 I am studying the patterns of distribution of whales around specific seabed structures. I am trying to create an interactive 3D plot showing at the same time: bathymetry as a surface ( x = longitude, y = latitude, z = depth), and geographic location of whale groups ( x = longitude, y = latitude, z = fixed depth -30 meters for example). Coordinates are projected in a UTM coordinate system. I usually work with R and the ggplot2 package for producing figures. Here, the plotly package seemed like

Place a chart in plotly popup

↘锁芯ラ 提交于 2019-12-03 14:06:49
I'm using plotly for R, although I'm open to using the Python version, as well. When I hover over a datapoint, is there a way to make the popup contain another chart? Ideally the chart would be created from the data, although I can use a static image as a fallback. I'm unsure where to start on this, and apologize in advance for not having an MWE. gdlmx Solution 1: Stick to R Thanks to @MLavoie. The following example use pure R to create two plot, the "mainplot" and the "hover" which reacts to the hover event of the first one. library(shiny) library(plotly) ui <- fluidPage( plotlyOutput(

Show legend and label axes in plotly 3D scatter plots

≡放荡痞女 提交于 2019-12-03 11:31:42
Sorry for keeping you busy with plotly questions today. Here would be another one: How would I show the legend and axes labels on plotly's new 3D scatter plots? E.g., if I have the following scatter plot in 2D that produced everything fine, I added another dimension but the axes labels don't show anymore (see code below), and the same problem with the legend. Any tips? Thanks! traces = [] for name in ('Iris-setosa', 'Iris-versicolor', 'Iris-virginica'): trace = Scatter3d( x=Y[y==name,0], y=Y[y==name,1], z=Y[y==name,2], mode='markers', name=name, marker=Marker( size=12, line=Line( color='rgba

ggplotly and geom_bar when using dates - latest version of plotly (4.7.0)

倖福魔咒の 提交于 2019-12-03 09:11:15
Say you have the following df: x <- as.Date(c("1963-06-01", "1964-06-01", "1965-06-01","1966-06-01")) y <- c(1162.7, 975.4, 1280.3, 1380.0) data<- data.frame(x, y) when you plot it using ggplot, everything seems to work: ggplot(data = data, aes(x = x, y = y)) + geom_bar(stat = "identity") ggplot works However, if we add a ggplotly wrap around it, the graph disappears. ggplotly(ggplot(data = data, aes(x = x, y = y)) + geom_bar(stat = "identity")) ggplotly doesn't work I get a warning message that says: We recommend that you use the dev version of ggplot2 with ggplotly() . Now, if I remove the

Can I recreate this polar coordinate spider chart in plotly?

只愿长相守 提交于 2019-12-03 09:06:31
问题 I'm having a bit of difficulty figuring out how to recreate the following graphic of a spider (or radar) chart, using plotly. Actually, I can't even recreate it in the most recent versions of ggplot2 because there have been breaking changes since 1.0.1. Here's an example graphic: Here's the original function that built it: http://pcwww.liv.ac.uk/~william/Geodemographic%20Classifiability/func%20CreateRadialPlot.r Here's an example of how the original function worked: http://rstudio-pubs-static

How to make a choropleth map with a slider using Plotly?

﹥>﹥吖頭↗ 提交于 2019-12-03 09:01:28
I'm recreating the example choropleth and trying to add a slider that, when dragged, would change from year to year. Another user asked a similar question but they didn't receive a reply. I did some more searching and found an example where the user generated random values for the additional years and created a slider but it's in JavaScript and I'm not sure how to translate it into Python. Here's the code in JavaScript: Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv', function(err, rows){ function unpack(rows, key) { return rows.map(function(row)

How to plot 3D scatter diagram using ggplot?

一笑奈何 提交于 2019-12-03 08:58:53
问题 I tried to use "plotly" function but It is not working in my case at all. "ggplot" is working is in a case of 2D but it is giving an error when adding one more axis. How to solve this issue? ggplot(data,aes(x=D1,y=D2,z=D3,color=Sample))+geom_point() How to add one more axis and get the 3D plot in this? Thank You. 回答1: Since you tagged your question with plotly and said that you've tried to use it with plotly, I think it would be helpful to give you a working code solution in plotly : Creating

Plotly: How can I change the format of hover-on labels?

╄→гoц情女王★ 提交于 2019-12-03 07:45:56
I've looked through online documentation, but couldn't find how to change the format of hover-on labels: For example, if I'd like to display the number as "~611 thousand" or something of the sort. Plotly tick and hover formatting are fully customizable using the python / d3 formatting language . From an API, use axis attributes 'tickformat' and 'hoverformat' to set the behavior. For example, this graph has 'layout.yaxis.hoverformat': ',f' . From the web app, input your formatting specs under "Axes" -> "Labels": Plotly allows for axis and hover format only String values, so you cant write your