plotly-python

Dropdown menu for Plotly Choropleth Map Plots

余生颓废 提交于 2020-08-17 06:59:09
问题 I am trying to create choropleth maps. Below is an example that works: df = px.data.gapminder().query("year==2007") fig = go.Figure(data=go.Choropleth( locations=happy['iso'], # Spatial coordinates z = happy['Happiness'].astype(float), # Data to be color-coded colorbar_title = "Happiness Score", )) fig.update_layout( title_text = 'Life Expectancy in 2007' ) fig.show() However, I would like to create a dropdown menu that will change the plotted values between different variables (e.g., Life

Plotly: treemap element with “href” not working

隐身守侯 提交于 2020-08-03 10:35:32
问题 I have simple table whin href link inside the text. But clicking on it doesn't open the page. is there any easy way to do that? import plotly.express as px df = px.data.gapminder().query("year == 2007") link_ref = '<a xlink:href="http://google.com" style="cursor: pointer" target="_blank" rel="noopener noreferrer">{}</a>' df['country'] = df['country'].apply(lambda item: link_ref.format(item, "{}")) fig = px.treemap(df, path=[ 'continent', 'country'], values='pop', color='lifeExp', hover_data=[

Plotly: treemap element with “href” not working

雨燕双飞 提交于 2020-08-03 10:34:41
问题 I have simple table whin href link inside the text. But clicking on it doesn't open the page. is there any easy way to do that? import plotly.express as px df = px.data.gapminder().query("year == 2007") link_ref = '<a xlink:href="http://google.com" style="cursor: pointer" target="_blank" rel="noopener noreferrer">{}</a>' df['country'] = df['country'].apply(lambda item: link_ref.format(item, "{}")) fig = px.treemap(df, path=[ 'continent', 'country'], values='pop', color='lifeExp', hover_data=[

Succint way to add line segments to plotly graph (with python/jupyter notebook)?

跟風遠走 提交于 2020-07-30 01:55:45
问题 I want to create a lollipop plot with several horizontal line segments like this - https://python-graph-gallery.com/184-lollipop-plot-with-2-group. I'd like to use plotly since I prefer the graphics (and easy interactivity) but can't find a succint way. There's both line graphs (https://plot.ly/python/line-charts/) and you can add lines in the layout (https://plot.ly/python/shapes/#vertical-and-horizontal-lines-positioned-relative-to-the-axes), but both of these solutions require each line

Succint way to add line segments to plotly graph (with python/jupyter notebook)?

你说的曾经没有我的故事 提交于 2020-07-30 01:52:45
问题 I want to create a lollipop plot with several horizontal line segments like this - https://python-graph-gallery.com/184-lollipop-plot-with-2-group. I'd like to use plotly since I prefer the graphics (and easy interactivity) but can't find a succint way. There's both line graphs (https://plot.ly/python/line-charts/) and you can add lines in the layout (https://plot.ly/python/shapes/#vertical-and-horizontal-lines-positioned-relative-to-the-axes), but both of these solutions require each line

Plotly: How to plot a cumulative “steps” histogram?

你离开我真会死。 提交于 2020-07-05 12:33:48
问题 I am trying to plot a cumulative histogram using Plotly in python, but make it look like "steps", i.e. bars with no color and only the top line is displayed. Something like this: Basically, I'm trying to reproduce the behavior of the following matplotlib code: import matplotlib.pyplot as plt plt.hist(x, cumulative=True, histtype='step') So far, the best I've been able to do is: import plotly.graph_objs as go from plotly.offline import iplot h = go.Histogram(x=x, cumulative=dict(enabled=True),

Plotly: How to plot a cumulative “steps” histogram?

▼魔方 西西 提交于 2020-07-05 12:32:41
问题 I am trying to plot a cumulative histogram using Plotly in python, but make it look like "steps", i.e. bars with no color and only the top line is displayed. Something like this: Basically, I'm trying to reproduce the behavior of the following matplotlib code: import matplotlib.pyplot as plt plt.hist(x, cumulative=True, histtype='step') So far, the best I've been able to do is: import plotly.graph_objs as go from plotly.offline import iplot h = go.Histogram(x=x, cumulative=dict(enabled=True),

Is there a way to create gantt charts in python?

爷,独闯天下 提交于 2020-06-27 08:31:26
问题 I want to create gantt charts in python using create_gantt. However I have issues when I have overlapping start and end dates. Eg: import plotly.plotly as py import plotly.figure_factory as ff import plotly df = [dict(Task="Milestone A", Start='2017-01-01', Finish='2017-02-02', Resource='Jack'), dict(Task="Milestone B", Start='2018-01-01', Finish='2018-02-02', Resource='Jack'), dict(Task="Milestone A", Start='2017-01-17', Finish='2017-04-28', Resource='Joe'), dict(Task="Milestone B", Start=

Use Pandas index in Plotly Express

半腔热情 提交于 2020-06-25 08:39:29
问题 Plotly Express allows me to easily plot a pandas dataframe, as explained in their examples. Rather than using a named column for x and a named column for y, I would like to use the dataframe's index for x and a named column for y. Example using named columns import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="sepal_width", y="sepal_length") fig.show() What i want (bogus example) import plotly.express as px iris = px.data.iris() fig = px.scatter(iris, x="index", y=

Plotly sunburst plot not showing in Jupyter notebook

橙三吉。 提交于 2020-06-25 05:40:41
问题 I am using Plotly and Jupyter to generate some visuals to better understand user journeys online. I am using the Plotly sunburst chart since this makes a great visual for that purpose. Plotly provides an example that works great and provides the visual that I am looking to produce with my own data. I have created a dataframe that mirrors the example but when I try to use .show() no chart is produced. It appears to run fine (no errors) and produces white space where the chart should be but not