问题
I was using plotly to try some things and then found that create_scatterplot is the only package that doesn't work. I mean, it clearly is in the module, as it appears when you call the help command:
NAME
plotly.figure_factory
FILE
/usr/lib/python2.7/site-packages/plotly/figure_factory/__init__.py
PACKAGE CONTENTS
_2d_density
_annotated_heatmap
_bullet
_candlestick
_county_choropleth
_dendrogram
_distplot
_facet_grid
_gantt
_ohlc
_quiver
_scatterplot
_streamline
_table
:
And in the plotly.py/plotly/figure_factory github folder
Is it down or something? I am quite new to programming, but I thought this kind of thing stayed local. Maybe I am losing something, can i fix this?
If you want to check some code:
from plotly import figure_factory as ff
help(ff)
from plotly.figure_factory import create_2d_density
from plotly.figure_factory import create_annotated_heatmap
from plotly.figure_factory import create_bullet
from plotly.figure_factory import create_candlestick
from plotly.figure_factory import create_county_choropleth
from plotly.figure_factory import create_dendrogram
from plotly.figure_factory import create_facet_grid
from plotly.figure_factory import create_gantt
from plotly.figure_factory import create_ohlc
from plotly.figure_factory import create_quiver
from plotly.figure_factory import create_scatterplot
from plotly.figure_factory import create_streamline
from plotly.figure_factory import create_table
And you can see it only returns errors with scatterplot and county_choropleth.
回答1:
As I see in github plotly.figure_factory at _county_choropleth you need just call this in another way:
from plotly.figure_factory._county_choropleth import create_choropleth
and call after:
fig = create_choropleth(bla-bla)
py.plot(fig, filename='basic-choropleth')
In situation with scatterplot you will need rename create_scatterplot
to just scatterplot
:
from plotly.figure_factory._scatterplot import scatterplot
and:
fig = scatterplot(bla-bla)
py.plot(fig, filename='basic-scatter')
Also I found that when you called create_choropleth
you need to install few packages link to avoid troubles:
pip install shapely
pip install geopandas
pip install pyshp
And don`t forget to update your plotly version:
pip install --upgrade plotly
Hope this information could help you
来源:https://stackoverflow.com/questions/52138413/plotly-figure-factory-create-scatterplot-stopped-working