Open sagrawal-idrc opened 5 years ago
For data which is here: http://www.sharecsv.com/s/76dd767525a37180ca54cd1d9314b9dc/t1.csv, the plot doesn't appear unless 0 is included in extent. I have described my experiments here too: https://stackoverflow.com/questions/57585433/facing-weird-problem-when-trying-to-plot-simple-lat-lon-points
0
This does not work:
test_ax = plt.axes(projection=ccrs.Mercator()) test_ax.plot(test_df['lon'], test_df['lat'], color="blue", linewidth=4, alpha=1.0, transform=ccrs.Geodetic()) test_ax.coastlines() test_ax.gridlines(draw_labels=True) plt.show()
This code shows the plot (the blue dot near San Francisco)
test_ax = plt.axes(projection=ccrs.Mercator()) test_ax.plot(test_df['lon'], test_df['lat'], color="blue", linewidth=4, alpha=1.0, transform=ccrs.Geodetic()) test_ax.coastlines() test_ax.set_extent([-130, 0, 30, 40], crs=ccrs.Geodetic()) test_ax.gridlines(draw_labels=True) plt.show()
(Edit-1 contains a reproducible example. I am adding a simplified reproducible example here).
import numpy as np import pandas as pd import matplotlib.pyplot as plt import cartopy.crs as ccrs test_df = pd.DataFrame() test_df['lon'] = np.linspace(-120, -60, num=1000) test_df['lat'] = 38 fig = plt.figure() test_ax = fig.add_axes((0, 0, 1, 0.3), projection=ccrs.Mercator()) test_ax.plot(test_df['lon'], test_df['lat'], color="blue", linewidth=4, alpha=1.0, transform=ccrs.Geodetic()) test_ax.coastlines() gl = test_ax.gridlines(draw_labels=True) gl.xlabels_top = False gl.ylabels_left = False test_ax.set_title('Path shows with {} points'.format(len(test_df))) test_df = pd.DataFrame() test_df['lon'] = np.linspace(-120, -60, num=1001) test_df['lat'] = 38 test_ax1 = fig.add_axes((0, 0.3, 1, 0.3), projection=ccrs.Mercator()) test_ax1.plot(test_df['lon'], test_df['lat'], color="blue", linewidth=4, alpha=1.0, transform=ccrs.Geodetic()) test_ax1.coastlines() gl = test_ax1.gridlines(draw_labels=True) gl.xlabels_top = False gl.ylabels_left = False test_ax1.set_title('Path does not show with {} points'.format(len(test_df))) test_ax2 = fig.add_axes((0, 0.6, 1, 0.4), projection=ccrs.Mercator()) test_ax2.plot(test_df['lon'], test_df['lat'], color="blue", linewidth=4, alpha=1.0, transform=ccrs.Geodetic()) test_ax2.coastlines() test_ax2.set_extent((-120, 0, 36, 38)) gl = test_ax2.gridlines(draw_labels=True) gl.xlabels_top = False gl.ylabels_left = False test_ax2.set_title('Path shows with {} points with 0 lon included in extent'.format(len(test_df))) plt.show()
I am adding a reproducible example (for jupyter notebook)
import matplotlib.pyplot as plt import cartopy.crs as ccrs import pandas as pd df_csv_url = 'http://www.sharecsv.com/dl/76dd767525a37180ca54cd1d9314b9dc/t1.csv' test_df = pd.read_csv(df_csv_url) figure_params = { 'width': 9.6, 'height': 5.4 } fig = plt.figure( figsize=(figure_params["width"], figure_params["height"]) ) test_ax = fig.add_axes((0, 0.5, 0.5, 0.5), projection=ccrs.Mercator(), label="map1") test_ax.plot(test_df['lon'], test_df['lat'], color="blue", linewidth=4, alpha=1.0, transform=ccrs.Geodetic()) test_ax.coastlines() test_ax.gridlines(draw_labels=True) test_ax.set_title("Path doesn\'t show", y=1.5) # Including 0 meridian in extent shows the path test_ax1 = fig.add_axes((0, 0, 0.5, 0.5), projection=ccrs.Mercator(), label="map2") test_ax1.plot(test_df['lon'], test_df['lat'], color="blue", linewidth=4, alpha=1.0, transform=ccrs.Geodetic()) test_ax1.set_extent([-130, 0, 30, 40], crs=ccrs.Geodetic()) test_ax1.coastlines() test_ax1.gridlines(draw_labels=True) test_ax1.set_title("Path shows (blue dot near San Francisco)", y=1.1) plt.show()
Well at least the 1000 point issue will be fixed by #1611 .
Description
For data which is here: http://www.sharecsv.com/s/76dd767525a37180ca54cd1d9314b9dc/t1.csv, the plot doesn't appear unless
0
is included in extent. I have described my experiments here too: https://stackoverflow.com/questions/57585433/facing-weird-problem-when-trying-to-plot-simple-lat-lon-pointsCode to reproduce
This does not work:
This code shows the plot (the blue dot near San Francisco)
Edit - 2
(Edit-1 contains a reproducible example. I am adding a simplified reproducible example here).
Edit - 1
I am adding a reproducible example (for jupyter notebook)
Full environment definition
### Operating system Ubuntu 18.04.3 LTS ### Cartopy version Cartopy==0.17.0 ### conda list NA ### pip list ``` Package Version ------------------ ----------- appdirs 1.4.3 argh 0.26.2 arrow 0.10.0 atomicwrites 1.3.0 attrs 19.1.0 backcall 0.1.0 beautifulsoup4 4.7.1 black 19.3b0 bleach 3.1.0 Cartopy 0.17.0 certifi 2019.3.9 chardet 3.0.4 Click 7.0 click-plugins 1.1.1 cligj 0.5.0 colorama 0.4.1 cycler 0.10.0 decorator 4.1.2 defusedxml 0.6.0 docopt 0.6.2 entrypoints 0.3 Fiona 1.8.6 idna 2.8 importlib-metadata 0.18 ipdb 0.10.3 ipykernel 5.1.1 ipython 6.2.1 ipython-genutils 0.2.0 ipywidgets 7.4.2 jedi 0.11.0 Jinja2 2.10.1 jsonschema 3.0.1 jupyter 1.0.0 jupyter-client 5.2.4 jupyter-console 6.0.0 jupyter-core 4.4.0 kiwisolver 1.1.0 lxml 4.3.3 MarkupSafe 1.1.1 matplotlib 3.1.0 mistune 0.8.4 more-itertools 7.0.0 munch 2.3.2 nbconvert 5.5.0 nbformat 4.4.0 notebook 5.7.8 numpy 1.16.3 olefile 0.44 packaging 19.0 pandas 0.24.2 pandocfilters 1.4.2 parso 0.1.0 pathtools 0.1.2 pendulum 2.0.5 pexpect 4.2.1 pickleshare 0.7.4 Pillow 4.3.0 pip 19.1.1 pluggy 0.12.0 prometheus-client 0.6.0 prompt-toolkit 1.0.15 ptyprocess 0.5.2 py 1.8.0 pygdal 2.2.3.5 Pygments 2.2.0 pyparsing 2.4.0 pyrsistent 0.15.2 pyshp 2.1.0 pytest 4.6.3 pytest-watch 4.2.0 python-dateutil 2.6.1 pytz 2019.1 pytzdata 2019.2 PyYAML 5.1.1 pyzmq 18.0.1 qtconsole 4.4.4 requests 2.22.0 scipy 1.3.0 Send2Trash 1.5.0 setuptools 41.0.1 Shapely 1.6.4.post2 simplegeneric 0.8.1 simplekml 1.3.1 six 1.11.0 soupsieve 1.9.1 sox 1.3.0 termcolor 1.1.0 terminado 0.8.2 testpath 0.4.2 toml 0.10.0 tornado 6.0.2 traitlets 4.3.2 urllib3 1.25.3 watchdog 0.9.0 wcwidth 0.1.7 webencodings 0.5.1 wheel 0.33.4 widgetsnbextension 3.4.2 zipp 0.5.1 ```