plotly

Hovermode using Plotly with R

梦想的初衷 提交于 2019-12-10 17:21:37
问题 Is there a way to code the hovermode when using plotly with R and ggplot2? Currently, my code is: plot <- ggplot(data, aes(var1, var2, text=var3)) + geom_point() py$ggplotly(plot) And I want the plotly graph to automatically have the hover mode set to "show closest data on hover" rather than "compare data on hover". 回答1: Add the following argument when calling ggplotly : py$ggplotly(plot, kwargs=list(layout=list(hovermode="closest"))) 回答2: The answer from 'mkcor' didn't work when trying to do

Can I get back info like: “hover location”, “Brush location” or “click location”

笑着哭i 提交于 2019-12-10 17:11:59
问题 I want to set up an interactive graph with shiny and plotly. Shiny has a build in feature to get info about the user interaction. Like: input$plot_click , input$plot_dblclick , input$plot_hover and input$plot_brush . See: http://shiny.rstudio.com/articles/plot-interaction.html Is there any option to get this over the Plotly API? Or can the API just handle one direction? Plotly is really cool. Would love to use it in my shiny apps. Thanks and best regards Nico 回答1: Yes, there are click and

How to create indefinite funcanimation frames dynamically updating in real time?

筅森魡賤 提交于 2019-12-10 16:59:05
问题 I am trying to recreate a population variance graph in python In that example, as soon as we start, the function runs immediately to I guess the limit of the environment set by website. I have managed to create similar graphs, but for animation I am stuck. Below is my code. import matplotlib.animation as animation fig, ax = plt.subplots(1,1,figsize=(5,4)) plt.close() frameRate = 30 global_counter = 0 def animate(i): ax.clear() global global_counter ax.text(0.5,0.5, 'test:{}'.format(global

Python Plotly format axis numbers as %

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 16:31:22
问题 Here's the dataframe df = pd.DataFrame({"col_1":[0.00143,0.00653,0.00732],"col_2":[0.00984,0.00192,0.00751]},index=['A','B','C']) Here's my plotly code: trace0 = go.Bar( x=[df.columns[0],df.columns[1]], y=[df.ix[0,0],df.ix[0,1]], name=df.index[0], # marker=dict(color=cof_pal[0] ) trace1 = go.Bar( x=[df.columns[0],df.columns[1]], y=[df.ix[1,0],df.ix[1,1]], name=df.index[1], # marker=dict(color=cof_pal[1] ) trace2 = go.Bar( x=[df.columns[0],df.columns[1]], y=[df.ix[2,0],df.ix[2,1]], name=df

How to plot sorted barplot in plolty3.10

与世无争的帅哥 提交于 2019-12-10 16:07:02
问题 I have been trying to plot sorted barplot in plotly for some stores sales data, but whatever I try it gives me the unsorted data. How to plot the sorted barplot using plotly. NOTE: https://community.plot.ly/t/sort-bars-in-bar-chart-by-value-and-have-each-bar-with-a-different-color/14562 Did not worked for me. Data import numpy as np import pandas as pd import plotly import plotly.offline as py import plotly.graph_objs as go from plotly.offline import plot, iplot, init_notebook_mode init

Embed Plotly HTML in PyCharm IDE

百般思念 提交于 2019-12-10 15:27:18
问题 I would like to see Plotly's HTML output in the PyCharm IDE. It currently says: Process finished with exit code 0 for the output. However, I receive a graphical result in Jupyter 回答1: To see the Plotly html output use the offline feature. For example, like this: plotly.offline.plot(*yourplotname*, filename='file.html') Run the code in pycharm and it will save the .html file locally in your work folder and open the .html in your browser to view. 回答2: Dnaiel, as far as I understand plotly, it

Pie Chart Labels Cut off

独自空忆成欢 提交于 2019-12-10 15:22:39
问题 I'm making a pie chart, and some of the labels get cut off. I'd like to shrink the plot to accommodate all the labels. Below is a reproducible example. library(plotly) plot_ly(type="pie",values=1:19, labels=c(101:119),textinfo="label+value+percent", textposition="outside",showlegend=F,marker=list(colors=c( "gray", "thistle", "red", "lightskyblue", "deeppink", "green", "gold", "brown", "purple", "orange", "cadetblue", "darkslategray", "burlywood", "yellow", "skyblue", "lightgreen", "hotpink",

plotly not getting geom_text in R / ggplot

℡╲_俬逩灬. 提交于 2019-12-10 13:55:37
问题 I have a ggplot that works fine by its own. But when I try to import it in to the plotly api system, the geom_text seems to not work - everything else works. Can anyone help me? Here's my R version - R version 3.1.2 (2014-10-31) and plotly version - 0.5.23 The data that I am using is in file.csv and looks like: Province,Community,General Shelters,General Beds,Mens Shelters,Mens Beds,Womens Shelters,Womens Beds,Youth Shelters,Youth Beds,Family Shelters,Family Beds,Total Shelters,Total Beds New

How to plot a vector field in Julia?

牧云@^-^@ 提交于 2019-12-10 12:56:26
问题 I want to plot a vector field in Julia. I could not find an example here. Here there are some examples using plotly , however, they do not work for me. I would like to plot the vector field by plotlyjs or plotly . Here is an example code in Julia: using Plots pyplot() x = collect(linspace(0,10,100)); X = repmat(x,1,length(x)); Y = repmat(x',length(x),1); U = cos.(X.*Y); V = sin.(X.*Y); streamplot(X,Y,U,V) Here is the Matlab example: [x,y] = meshgrid(0:0.2:2,0:0.2:2); u = cos(x).*y; v = sin(x)

How can I vary opacity in a plotly R chart

被刻印的时光 ゝ 提交于 2019-12-10 12:49:10
问题 Here is an toy example. The opacity value in data.frame has no impact library(plotly) df <- data.frame(x=c(1,2),y=c(6,3),opacity=c(1,0.2)) plot_ly(df, type="bar", x=x, y=y, opacity=opacity, marker = list( color='#5a22e3' ) ) I might also want to extend have a color column in df and utilize that in place of the fixed value above TIA 回答1: You can add a group so that it knows to look for more than one opacity: plot_ly(df, type="bar", x=x, y=y, group=x, opacity=opacity, marker = list( color='