前提・実現したいこと
cartopyとmatplotlibを使って日本地図を描画しようとしています.
ひとまず,描画の中心の経度を変更して,日本が中心に表示されるようにしたいです.
発生している問題・エラーメッセージ
中心経度を指定しなければ世界地図を描画はできるのですが,中心経度を変更しようとするとエラーが出てしまいます.
ax = plt.axes(projection=ccrs.PlateCarree())の状態では地図が描画できます.
File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/IPython/core/formatters.py", line 341, in __call__ return printer(obj) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/IPython/core/pylabtools.py", line 248, in <lambda> png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs)) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/IPython/core/pylabtools.py", line 132, in print_figure fig.canvas.print_figure(bytes_io, **kw) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2193, in print_figure self.figure.draw(renderer) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/figure.py", line 1863, in draw mimage._draw_list_compositing_images( File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/cartopy/mpl/geoaxes.py", line 479, in draw return matplotlib.axes.Axes.draw(self, renderer=renderer, **kwargs) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper return func(*inner_args, **inner_kwargs) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 2747, in draw mimage._draw_list_compositing_images(renderer, self, artists) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/cartopy/mpl/feature_artist.py", line 189, in draw projected_geom = ax.projection.project_geometry( File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/cartopy/crs.py", line 218, in project_geometry return getattr(self, method_name)(geometry, src_crs) File "/Users/daichi/opt/anaconda3/lib/python3.8/site-packages/cartopy/crs.py", line 224, in _project_line_string return cartopy.trace.project_linear(geometry, src_crs, self) File "lib/cartopy/trace.pyx", line 608, in cartopy.trace.project_linear File "lib/cartopy/trace.pyx", line 82, in cartopy.trace.geos_from_shapely TypeError: an integer is required <Figure size 432x288 with 1 Axes>
該当のソースコード
python
1import matplotlib.pyplot as plt 2import cartopy.crs as ccrs 3import matplotlib.ticker as mticker 4import numpy as np 5 6fig = plt.figure() 7 8ax = plt.axes(projection=ccrs.PlateCarree(central_longitude=158)) 9ax.coastlines(resolution='10m') 10 11plt.show()
試したこと
central_longitude=158の数字をいじってみたり,数字だけを引数にしてみたりしたのですが,改善はされませんでした.
補足情報(FW/ツールのバージョンなど)
anaconda(python3.8.8)
matplotlib 3.3.4
cartopy 0.18.0
の環境でやっています
あなたの回答
tips
プレビュー