Python 3.x Can';t用mpl单张展示贴片
我试图在传单地图上显示一个固定大小的圆圈 我尝试了Python 3.x Can';t用mpl单张展示贴片,python-3.x,matplotlib,leaflet,plotly,Python 3.x,Matplotlib,Leaflet,Plotly,我试图在传单地图上显示一个固定大小的圆圈 我尝试了.add_artist()(请参阅),现在我正在尝试.add_patch() 您可以尝试取消注释这两行中的一行,无论哪一行未注释,都会弹出相同的错误 这是我得到的线索: Traceback (most recent call last): File "<ipython-input-81-1fdd7f4a9d12>", line 16, in <module> mplleaflet.show(fig = ax.
.add_artist()
(请参阅),现在我正在尝试.add_patch()
您可以尝试取消注释这两行中的一行,无论哪一行未注释,都会弹出相同的错误
这是我得到的线索:
Traceback (most recent call last):
File "<ipython-input-81-1fdd7f4a9d12>", line 16, in <module>
mplleaflet.show(fig = ax.figure)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\_display.py", line 180, in show
save_html(fig, fileobj=f, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\_display.py", line 131, in save_html
html = fig_to_html(fig, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\_display.py", line 84, in fig_to_html
exporter.run(fig)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\mplexporter\exporter.py", line 51, in run
self.crawl_fig(fig)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\mplexporter\exporter.py", line 118, in crawl_fig
self.crawl_ax(ax)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\mplexporter\exporter.py", line 138, in crawl_ax
self.draw_patch(ax, patch)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\mplexporter\exporter.py", line 227, in draw_patch
mplobj=patch)
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\leaflet_renderer.py", line 125, in draw_path
rings = list(iter_rings(data, pathcodes))
File "C:\ProgramData\Anaconda3\lib\site-packages\mplleaflet\utils.py", line 14, in iter_rings
raise ValueError('Unrecognized code: {}'.format(code))
ValueError: Unrecognized code: C
到
在mpl传单\utils.py
第11行和第12行。以下是我得到的:
===========================
编辑2以回答评论
mpl.patchers.Rectangle
和plt.Rectangle
显示:
rect1 = mpl.patches.Rectangle((x,y), 1, 1, color = 'r')
rect2 = plt.Rectangle((x, y), 1, 1, fc='r')
它似乎与一个纬度为1度、经度为1度的矩形相匹配(请参阅)(可能?看起来有点小)
至于多边形,那么。。。至少他们出现了,但我想这是一个投影问题:
regpol1 = mpl.patches.RegularPolygon((x,y), 100, radius=r, color = 'r')
cirpol1 = mpl.patches.CirclePolygon((x +50,y), radius=r, color = 'b')
这是
圆的问题吗
还是像矩形
或多边形
这样的不同面片也会导致此错误?@ImportanceOfBeingErnest请参见编辑2以回答您的问题。
elif code == 'L' or code == 'Z' or code == 'S' or code == 'C': ring.append(point)
rect1 = mpl.patches.Rectangle((x,y), 1, 1, color = 'r')
rect2 = plt.Rectangle((x, y), 1, 1, fc='r')
regpol1 = mpl.patches.RegularPolygon((x,y), 100, radius=r, color = 'r')
cirpol1 = mpl.patches.CirclePolygon((x +50,y), radius=r, color = 'b')