plotly

plotly adding a source or caption to a chart

爱⌒轻易说出口 提交于 2019-12-07 05:25:43
问题 Is there a way to add a data source / caption to a chart in Plotly, similar with what can be done in ggplot with the caption argument: labs(caption = "source: data i found somewhere") i.e., so we can display the data source at the bottom right of the graph, in a smaller font. 回答1: annotation offers a simple way to add a caption to a chart in plotly : library(plotly) plot_ly(x=~hp, y=~mpg, data=mtcars, type="scatter", mode="marker") %>% layout(annotations = list(x = 1, y = -0.1, text = "Source

R: Set Plotly hovermode to “compare data on hover”

可紊 提交于 2019-12-07 05:24:18
问题 I am trying to create a stacked area chart in R using the Plotly package as part of a Shiny app and would like to compare the data on hover. However, I am hiding the mode bar for design reasons, so I need to declare this option in my code as currently the hover is only shown for the closest data point to the cursor. However, the Plotly for R reference only gives the options "x" (tooltip on the x-axis), "y" (tooltip on the y axis), "closest" (shows the tooltip for the closest data point to the

R plotly stacked bar chart with over 100 categories

廉价感情. 提交于 2019-12-07 05:14:58
问题 I have a dataset that contains over 100 categories. If I am going to plot it, I have to write over 100 lines code for it. Here is the example from plotly official website: library(plotly) Animals <- c("giraffes", "orangutans", "monkeys") SF_Zoo <- c(20, 14, 23) LA_Zoo <- c(12, 18, 29) data <- data.frame(Animals, SF_Zoo, LA_Zoo) p <- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>% add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>% layout(yaxis = list(title = 'Count'),

Categorical axis order in plotly.js

丶灬走出姿态 提交于 2019-12-07 03:09:41
问题 I have a plotly.js bar chart that I am trying to get the order of the categorical axis right. Each category has a single bar, but sometimes they are green and sometimes they are yellow. The bars should be in order from highest to lowest, but plotly seems to order them based on the different fills. The data: var data = [ { "marker": { "color": "#006666" }, "x": ["A:0122", "A:0121", "A:0434", "A:0838", "A:0083", "A:0081", "A:0687"], "y": [1246.0, 1096.0, 1000.0, 200.0, 0.0, 0.0, 0.0], "name":

Plotly.js - gd.data must be an array

a 夏天 提交于 2019-12-07 01:01:30
问题 I am using the Plotly.js library to draw 3D graphs. My plan is to draw 4 traces into one 3D graph. But I encounter some strange behavior of my website when I try do this. Sometimes, when I load my site I get no error and all 4 traces are loaded perfectly in my 3D graph. But at another time not all of my traces are loaded into my graph and I get the error: Error: gd.data must be an array. This is my function for adding the traces from a CSV file: function addTraceFromCSVdarkColor(divname,link)

R plot dynamic wind direction as arrow over time

我怕爱的太早我们不能终老 提交于 2019-12-07 00:18:28
I want to plot the wind over a very long time,thus a dynamic plot is a nice choice for others to choose the time range. And I want to display the wind direction as arrows ; wind speed could be line . But it will be messy if I add arrows to every line above, and it seems hard to add more date to x axis. What the final result I want to get is like this: Is it possible to plot the wind-arrow plot in R? Plus: here is the demo data for plot structure(list(date = c("2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04

Plotly-Dash: Want two stacked bar charts side by side from single df column

我与影子孤独终老i 提交于 2019-12-06 21:57:36
I am trying to get two stacked bar charts side by side but cannot figure it out. Here's an example df: Field Issue Police Budget cuts Research Budget cuts Police Time consuming Banking Lack of oversight Healthcare Lack of support Research Bureaucracy Healthcare Bureaucracy Banking Mistrust What I want is a stacked bar chart of of field first. It will have a height of 8 broken down by 2 police, 2 x research etc. Then I want a stacked bar chart of Issue next to the first chart. This second one will have a height of 8 and be stacked by 2 x budget cuts, 1 x time consuming, 1 x lack of oversight

Plotly legend title

戏子无情 提交于 2019-12-06 17:11:43
问题 I'd like to be able to add a title to the legend, in the following code. However, looking at the docs, I don't think there is a method for this. import plotly.plotly as py import plotly.graph_objs as go trace0 = go.Scatter( x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 5], ) trace1 = go.Scatter( x=[1, 2, 3, 4, 5], y=[5, 4, 3, 2, 1], ) data = [trace0, trace1] fig = go.Figure(data=data) py.iplot(fig, filename='default-legend') 回答1: Update: For not defining the legend but having the annotation positioned

Plotting a circle in leaflet using .add_artist()

孤街浪徒 提交于 2019-12-06 16:47:38
Starting from here and the first example from here , I'm trying to use pyplot and mplleaflet to plot a fixed-size circle on a map. (By "fixed-size", I mean that this circle is not a marker, it shouldn't adapt to the zoom level, but should stay of, say, 25m diameter whatever the zoom level). Here is what I got : import mplleaflet import matplotlib.pyplot as plt import matplotlib as mpl fig, ax = plt.subplots() x = 2.363561 y = 48.951918 r = 20 circle1 = mpl.patches.Circle((x,y), radius=r) circle2= plt.Circle((x, y), r, color='r') ax.add_artist(circle1) ax.add_artist(circle2) mplleaflet.show(fig

KeyError: 'plotly_domain' when using plotly to do scatter plot in python

元气小坏坏 提交于 2019-12-06 16:36:45
问题 I'm using plotly to do scatter plot. The graph is generated on my account but the terminal still reports an error: Traceback (most recent call last): File "IEORE4709HW1.py", line 106, in <module> py.iplot(data, filename='basic-scatter') File "/Library/Python/2.7/site-packages/plotly/plotly/plotly.py", line 175, in iplot return tools.embed(url, **embed_options) File "/Library/Python/2.7/site-packages/plotly/tools.py", line 412, in embed != session.get_session_config()['plotly_domain']):