python如何导入matplotlib_python – 从matplotlib导入地理图到plotly

import mpl_toolkits

import mpl_toolkits.basemap

#

# specify the map boundaries and projection type

#

mymap = mpl_toolkits.basemap.Basemap(llcrnrlon= -120, llcrnrlat=22,

urcrnrlon=-58, urcrnrlat=48,

projection="tmerc", lon_0 = -95, lat_0 = 35,

resolution = "l")

fig_map = plt.figure(6, figsize=(10, 8))

mymap.fillcontinents(color = "lightgray")

mymap.drawcoastlines(color = "gray", linewidth=1.2)

mymap.drawcountries(color = "gray", linewidth=2)

mymap.drawstates(color = "gray")

mymap.drawmapboundary()

plt.show()

而matplotlib给了我这个美丽的情节:

现在,我想将这个导入到情节不合时宜的情节中

py.iplot_mpl(fig_map, filename='DataScience/data-visualization/geographic_map_plot_1')

/usr/local/lib/python2.7/dist-packages/plotly/matplotlylib/renderer.py:479: UserWarning:

I found a path object that I don't think is part of a bar chart. Ignoring.

我收到几个奇怪的错误,如下所示:

---------------------------------------------------------------------------

KeyError Traceback (most recent call last)

in ()

----> 1 py.iplot_mpl(fig_map, filename='DataScience/data-visualization/geographic_map_plot_1')

/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.pyc in iplot_mpl(fig, resize, strip_style, update, **plot_options)

257 "object. Run 'help(plotly.graph_objs.Figure)' for more info."

258 )

--> 259 return iplot(fig, **plot_options)

260

261

/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.pyc in iplot(figure_or_data, **plot_options)

113 if 'auto_open' not in plot_options:

114 plot_options['auto_open'] = False

--> 115 res = plot(figure_or_data, **plot_options)

116 urlsplit = res.split('/')

117 username, plot_id = urlsplit[-2][1:], urlsplit[-1] # TODO: HACKY!

/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.pyc in plot(figure_or_data, validate, **plot_options)

185 "seeing this error:\n\n{0}"

186 "".format(err))

--> 187 if not figure['data']:

188 raise exceptions.PlotlyEmptyDataError(

189 "Empty data list found. Make sure that you populated the "

KeyError: 'data'

我没有在地理地图上看到任何关于情节的例子!所以,非常感谢任何帮助!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值