Skip to content
/ cartopy Public
  • Notifications You must be signed in to change notification settings
  • Fork 359
  • Star 1.4k
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jump to bottom

data color is adopted as additional map border color #1133

Closed
Swanson-Hysell opened this issue Sep 27, 2018 · 7 comments
Closed

data color is adopted as additional map border color #1133

Swanson-Hysell opened this issue Sep 27, 2018 · 7 comments

Comments

@Swanson-Hysell
Copy link

Swanson-Hysell commented Sep 27, 2018

Description

When plotting a small circle in cartopy, I am getting an issue where the color of that plotted data is also being adopted around the entire map as in this image where red can be seen in addition to the black outline:

screen shot 2018-09-27 at 10 43 44 am

Code to reproduce

x = [-149.99, -143.82, -140.38, -140.40, -143.15, -147.54, -152.45, -156.84, -159.59, -159.61, -156.17, -149.99, -149.99]
y = [64.99, 64.07, 61.74, 58.93, 56.53, 55.17, 55.17, 56.53, 58.93, 61.74, 64.07, 64.99, 64.99]

fig = plt.figure(figsize=(8,8))
map_projection = ccrs.Orthographic(central_longitude=200,central_latitude=30)
ax = plt.axes(projection = map_projection)
plt.plot(x, y, color='red', transform=ccrs.Geodetic())

screen shot 2018-09-27 at 10 46 52 am

Full environment definition

Operating system

Mac OS 10.13.16

Cartopy version

cartopy 0.16.0 py36h81b52dc_2 conda-forge

conda list

# packages in environment at /anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py36_0  
alabaster                 0.7.11                   py36_0  
anaconda                  custom           py36ha4fed55_0  
anaconda-client           1.7.1                    py36_0  
anaconda-navigator        1.8.7                    py36_0  
anaconda-project          0.8.2                    py36_0  
appdirs                   1.4.3            py36h28b3542_0  
appnope                   0.1.0            py36hf537a9a_0  
appscript                 1.0.1            py36h1de35cc_1  
asn1crypto                0.24.0                   py36_0  
astroid                   2.0.2                    py36_0  
astropy                   3.0.4            py36h1de35cc_0  
atomicwrites              1.1.5                    py36_0  
attrs                     18.1.0                   py36_0  
automat                   0.7.0                    py36_0  
babel                     2.6.0                    py36_0  
backcall                  0.1.0                    py36_0  
backports                 1.0                      py36_1  
backports.lzma            0.0.11           py36hd0afa68_0    anaconda
backports.shutil_get_terminal_size 1.0.0                    py36_2  
basemap                   1.1.0            py36h50ae964_7    conda-forge
beautifulsoup4            4.6.1                    py36_0  
bitarray                  0.8.3            py36h1de35cc_0  
bkcharts                  0.2              py36h073222e_0  
blas                      1.0                         mkl  
blaze                     0.11.3                   py36_0  
bleach                    2.1.3                    py36_0  
blosc                     1.14.3               hd9629dc_0  
bokeh                     0.13.0                   py36_0  
boto                      2.49.0                   py36_0  
bottleneck                1.2.1            py36h1d22016_1  
bzip2                     1.0.6                h1de35cc_5  
ca-certificates           2018.8.24            ha4d7672_0    conda-forge
cartopy                   0.16.0           py36h81b52dc_2    conda-forge
certifi                   2018.8.24             py36_1001    conda-forge
cffi                      1.11.5           py36h342bebf_0  
cftime                    1.0.0b1          py36h1d22016_0  
chardet                   3.0.4                    py36_1  
click                     6.7              py36hec950be_0  
cloudpickle               0.5.3                    py36_0  
clyent                    1.2.2                    py36_1  
colorama                  0.3.9            py36hd29a30c_0  
conda                     4.5.11                   py36_0    conda-forge
conda-build               3.12.1                   py36_0  
conda-env                 2.6.0                         1  
conda-verify              3.1.0                    py36_0  
constantly                15.1.0           py36h28b3542_0  
contextlib2               0.5.5            py36hd66e5e7_0  
cryptography              2.3              py36hdbc3d79_0  
cryptography-vectors      2.3                      py36_0  
curl                      7.61.0               ha441bb4_0  
cycler                    0.10.0           py36hfc81398_0  
cython                    0.28.5           py36h0a44026_0  
cytoolz                   0.9.0.1          py36h1de35cc_1  
dask                      0.18.2                   py36_0  
dask-core                 0.18.2                   py36_0  
datashape                 0.5.4                    py36_1  
dbus                      1.13.2               h760590f_1  
decorator                 4.3.0                    py36_0  
distributed               1.22.1                   py36_0  
docutils                  0.14             py36hbfde631_0  
entrypoints               0.2.3                    py36_2  
et_xmlfile                1.0.1            py36h1315bdc_0  
expat                     2.2.5                hb8e80ba_0  
fastcache                 1.0.2            py36h1de35cc_2  
ffmpeg                    4.0.2                ha6a6e2b_0    conda-forge
filelock                  3.0.4                    py36_0  
flask                     1.0.2                    py36_1  
flask-cors                3.0.6                    py36_0  
freetype                  2.8.1                hfa320df_1    conda-forge
future                    0.16.0                   py36_1  
geos                      3.6.2                hfc679d8_3    conda-forge
get_terminal_size         1.0.0                h7520d66_0  
gettext                   0.19.8.1             h15daf44_3  
gevent                    1.3.5            py36h1de35cc_0  
glib                      2.56.1               h35bc53a_0  
glob2                     0.6                      py36_0  
gmp                       6.1.2                hb37e062_1  
gmpy2                     2.0.8            py36h6ef4df4_2  
gnutls                    3.5.19               h2a4e5f8_1    conda-forge
greenlet                  0.4.14           py36h1de35cc_0  
h5py                      2.8.0            py36h3c9e6ae_0  
hdf4                      4.2.13               h39711bb_2  
hdf5                      1.10.2               hfa1e0ec_1  
heapdict                  1.0.0                    py36_2  
html5lib                  1.0.1                    py36_0  
hyperlink                 18.0.0                   py36_0  
icu                       58.2                 h4b95b61_1  
idna                      2.7                      py36_0  
imageio                   2.3.0                      py_1    conda-forge
imagesize                 1.0.0                    py36_0  
incremental               17.5.0                   py36_0  
intel-openmp              2018.0.3                      0  
ipykernel                 4.8.2                    py36_0  
ipython                   6.5.0                    py36_0  
ipython_genutils          0.2.0            py36h241746c_0  
ipywidgets                7.4.0                    py36_0  
isort                     4.3.4                    py36_0  
itsdangerous              0.24                     py36_1  
jbig                      2.1                  h4d881f8_0  
jdcal                     1.4                      py36_0  
jedi                      0.12.1                   py36_0  
jinja2                    2.10                     py36_0  
jpeg                      9c                   h470a237_1    conda-forge
jsonschema                2.6.0            py36hb385e00_0  
jupyter                   1.0.0                    py36_4  
jupyter_client            5.2.3                    py36_0  
jupyter_console           5.2.0                    py36_1  
jupyter_core              4.4.0                    py36_0  
jupyterlab                0.33.8                   py36_0  
jupyterlab-latex          0.3.1                     <pip>
jupyterlab_launcher       0.11.2                   py36_0  
keyring                   13.2.1                   py36_0  
kiwisolver                1.0.1            py36h0a44026_0  
lazy-object-proxy         1.3.1            py36h1de35cc_2  
libcurl                   7.61.0               hf30b1f0_0  
libcxx                    4.0.1                h579ed51_0  
libcxxabi                 4.0.1                hebd6815_0  
libedit                   3.1.20170329         hb402a30_2  
libffi                    3.2.1                h475c297_4  
libgfortran               3.0.1                h93005f0_2  
libiconv                  1.15                 hdd342a3_7  
libnetcdf                 4.6.1                h4e6abe9_1  
libpng                    1.6.34               he12f830_0  
libsodium                 1.0.16               h3efe00b_0  
libssh2                   1.8.0                h322a93b_4  
libtiff                   4.0.9                hcb84e12_1  
libxml2                   2.9.8                hab757c2_1  
libxslt                   1.1.32               hb819dd2_0  
llvmlite                  0.24.0           py36hc454e04_0  
locket                    0.2.0            py36hca03003_1  
lxml                      4.2.4            py36hef8c89e_0  
lzo                       2.10                 h362108e_2  
markupsafe                1.0              py36h1de35cc_1  
matlab-kernel             0.15.1                    <pip>
matlabengineforpython     R2018a                    <pip>
matplotlib                2.2.2                    py36_1    conda-forge
mccabe                    0.6.1                    py36_1  
metakernel                0.20.14                    py_0    conda-forge
mistune                   0.8.3            py36h1de35cc_1  
mkl                       2018.0.3                      1  
mkl-service               1.1.2            py36h6b9c3cc_4  
mkl_fft                   1.0.4            py36h5d10147_1  
mkl_random                1.0.1            py36h5d10147_1  
more-itertools            4.3.0                    py36_0  
mpc                       1.1.0                h6ef4df4_1  
mpfr                      4.0.1                h3018a27_3  
mpmath                    1.0.0                    py36_2  
msgpack-python            0.5.6            py36h04f5b5a_1  
multipledispatch          0.5.0                    py36_0  
navigator-updater         0.2.1                    py36_0  
nbconvert                 5.3.1                    py36_0  
nbformat                  4.4.0            py36h827af21_0  
ncurses                   6.1                  h0a44026_0  
netcdf4                   1.4.1            py36h08833f9_0  
nettle                    3.3                           0    conda-forge
networkx                  2.1                      py36_0  
nltk                      3.3.0                    py36_0  
nodejs                    8.11.3               h0a44026_0  
nose                      1.3.7                    py36_2  
notebook                  5.6.0                    py36_0  
numba                     0.39.0           py36h6440ff4_0  
numexpr                   2.6.6            py36h4f467ca_0  
numpy                     1.13.3           py36ha9ae307_4  
numpy-base                1.15.0           py36h8a80b8c_0  
numpydoc                  0.8.0                    py36_0  
octave_kernel             0.28.4                     py_1    conda-forge
odo                       0.5.1            py36hc1af34a_0  
olefile                   0.45.1                   py36_0  
openh264                  1.7.0                         0    conda-forge
openpyxl                  2.5.5                    py36_0  
openssl                   1.0.2p               h470a237_0    conda-forge
owslib                    0.17.0                     py_0    conda-forge
packaging                 17.1                     py36_0  
pandas                    0.23.4           py36hf8a1672_0    conda-forge
pandoc                    2.2.1                h1a437c5_0  
pandocfilters             1.4.2                    py36_1  
parso                     0.3.1                    py36_0  
partd                     0.3.8            py36hf5c4cb8_0  
path.py                   11.0.1                   py36_0  
pathlib2                  2.3.2                    py36_0  
patsy                     0.5.0                    py36_0  
pcre                      8.42                 h378b8a2_0  
pep8                      1.7.1                    py36_0  
pexpect                   4.6.0                    py36_0  
pickleshare               0.7.4            py36hf512f8e_0  
pillow                    5.2.0            py36h2dc6135_1    conda-forge
pip                       10.0.1                   py36_0  
pkginfo                   1.4.2                    py36_1  
pluggy                    0.7.1                    py36_0  
ply                       3.11                     py36_0  
proj4                     4.9.3                h470a237_8    conda-forge
prometheus_client         0.3.1                    py36_0  
prompt_toolkit            1.0.15           py36haeda067_0  
psutil                    5.4.6            py36h1de35cc_0  
ptyprocess                0.6.0                    py36_0  
py                        1.5.4                    py36_0  
pyasn1                    0.4.4                    py36_0  
pyasn1-modules            0.2.2                    py36_0  
pycodestyle               2.4.0                    py36_0  
pycosat                   0.6.3            py36h1de35cc_0  
pycparser                 2.18                     py36_1  
pycrypto                  2.6.1            py36h1de35cc_9  
pycurl                    7.43.0.2         py36hdbc3d79_0  
pyepsg                    0.3.2                      py_1    conda-forge
pyflakes                  2.0.0                    py36_0  
pygments                  2.2.0            py36h240cd3f_0  
pylint                    2.1.1                    py36_0  
pyodbc                    4.0.23           py36h0a44026_0  
pyopenssl                 18.0.0                   py36_0  
pyparsing                 2.2.0                    py36_1  
pyproj                    1.9.5.1          py36h508ed2a_5    conda-forge
pyqt                      5.9.2            py36h655552a_0  
pyshp                     1.2.12                     py_0    conda-forge
pysocks                   1.6.8                    py36_0  
pytables                  3.4.4            py36h13cba08_0  
pytest                    3.7.1                    py36_0  
pytest-arraydiff          0.2              py36h39e3cac_0  
pytest-astropy            0.4.0                    py36_0  
pytest-doctestplus        0.1.3                    py36_0  
pytest-openfiles          0.3.0                    py36_0  
pytest-remotedata         0.3.0                    py36_0  
python                    3.6.6                hc167b69_0  
python-dateutil           2.7.3                    py36_0  
python.app                2                        py36_8  
pytz                      2018.5                   py36_0  
pywavelets                0.5.2            py36h1d22016_2  
pyyaml                    3.13             py36h1de35cc_0  
pyzmq                     17.1.0           py36h1de35cc_0  
qt                        5.9.6                h74ce4d9_0  
qtawesome                 0.4.4            py36h468c6fb_0  
qtconsole                 4.3.1            py36hd96c0ff_0  
qtpy                      1.4.2                    py36_1  
readline                  7.0                  hc1231fa_4  
requests                  2.19.1                   py36_0  
rope                      0.10.7                   py36_0  
ruamel_yaml               0.15.46          py36h1de35cc_0  
scikit-image              0.14.0           py36h0a44026_1  
scikit-learn              0.19.1           py36hf9f1f73_0  
scipy                     1.1.0            py36hf1f7d93_0  
scripttest                1.3                      py36_0    omnia
seaborn                   0.9.0                    py36_0  
send2trash                1.5.0                    py36_0  
service_identity          17.0.0           py36h28b3542_0  
setuptools                40.0.0                   py36_0  
shapely                   1.6.4            py36h164cb2d_1    conda-forge
simplegeneric             0.8.1                    py36_2  
singledispatch            3.4.0.3          py36hf20db9d_0  
sip                       4.19.8           py36h0a44026_0  
six                       1.11.0                   py36_1  
snappy                    1.1.7                he62c110_3  
snowballstemmer           1.2.1            py36h6c7b616_0  
sortedcollections         1.0.1                    py36_0  
sortedcontainers          2.0.4                    py36_0  
sphinx                    1.7.6                    py36_0  
sphinxcontrib             1.0                      py36_1  
sphinxcontrib-websupport  1.1.0                    py36_1  
spyder                    3.3.0                    py36_0  
spyder-kernels            0.2.4                    py36_0  
sqlalchemy                1.2.10           py36h1de35cc_0  
sqlite                    3.24.0               ha441bb4_0  
statsmodels               0.9.0            py36h1d22016_0  
sympy                     1.2                      py36_0  
tblib                     1.3.2            py36hda67792_0  
terminado                 0.8.1                    py36_1  
testpath                  0.3.1            py36h625a49b_0  
tk                        8.6.8                ha92aebf_0    conda-forge
toolz                     0.9.0                    py36_0  
tornado                   5.1              py36h1de35cc_0  
traitlets                 4.3.2            py36h65bd3ce_0  
twisted                   17.5.0                   py36_0  
typed-ast                 1.1.0            py36h1de35cc_0  
typing                    3.6.4                    py36_0  
unicodecsv                0.14.1           py36he531d66_0  
unixodbc                  2.3.6                h3efe00b_0  
urllib3                   1.23                     py36_0  
wcwidth                   0.1.7            py36h8c6ec74_0  
webencodings              0.5.1                    py36_1  
werkzeug                  0.14.1                   py36_0  
wheel                     0.31.1                   py36_0  
widgetsnbextension        3.4.0                    py36_0  
wrapt                     1.10.11          py36h1de35cc_2  
wxpython                  4.0.3            py36hebc47a7_0    anaconda
x264                      1!152.20180717       h470a237_1    conda-forge
xlrd                      1.1.0                    py36_1  
xlsxwriter                1.0.5                    py36_0  
xlwings                   0.11.8                   py36_0  
xlwt                      1.2.0            py36h5ad1178_0  
xz                        5.2.4                h1de35cc_4  
yaml                      0.1.7                hc338f04_2  
zeromq                    4.2.5                h0a44026_0  
zict                      0.1.3                    py36_0  
zlib                      1.2.11               hf3cbc9b_2  
zope                      1.0                      py36_0  
zope.interface            4.5.0            py36h1de35cc_0

pip list

@Swanson-Hysell Swanson-Hysell mentioned this issue Sep 27, 2018
implementing an alternative to basemap PmagPy/PmagPy#292
Closed
@ajdawson
Copy link
Member

ajdawson commented Sep 27, 2018

This is not the case if you specify the coordinate system as PlateCarree() (and set a global extent):

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

x = [-149.99, -143.82, -140.38, -140.40, -143.15, -147.54, -152.45, -156.84, -159.59, -159.61, -156.17, -149.99, -149.99]
y = [64.99, 64.07, 61.74, 58.93, 56.53, 55.17, 55.17, 56.53, 58.93, 61.74, 64.07, 64.99, 64.99]

fig = plt.figure(figsize=(8,8))
map_projection = ccrs.Orthographic(central_longitude=200,central_latitude=30)
ax = plt.axes(projection = map_projection)
plt.plot(x, y, color='red', transform=ccrs.PlateCarree())
ax.set_global()

plt.show()

figure_1

@Swanson-Hysell
Copy link
Author

Swanson-Hysell commented Sep 27, 2018

Thanks. However, I think I need to rely on ccrs.Geodetic() rather than ccrs.PlateCarree() due to dateline issues.

For example, if we shift that circle over:

x = [-180.0, -173.90392209668542, -170.2164107541611, -169.89515168493494, -172.58907203869072, -177.29473041640921, 177.29473041640921, 172.58907203869072, 169.89515168493494, 170.2164107541611, 173.90392209668536, -180.0, -180.0]
y = [39.014507062781554, 37.444947415765881, 33.383435919700013, 28.327900326457918, 23.882635471621096, 21.311671071379525, 21.311671071379525, 23.882635471621096, 28.327900326457918, 33.383435919700013, 37.444947415765853, 39.014507062781554, 39.014507062781554]

fig = plt.figure(figsize=(8,8))
map_projection = ccrs.Orthographic(central_longitude=200,central_latitude=30)
ax = plt.axes(projection = map_projection)
plt.plot(x, y, color='red', transform=ccrs.PlateCarree())
ax.set_global()
plt.show()

screen shot 2018-09-27 at 11 37 24 am

@ajdawson
Copy link
Member

ajdawson commented Sep 27, 2018

Yeah sorry, my comment was intended as of a point of interest for debugging rather than a solution. I'm not sure what is wrong, I tried applying the transform manually to see if there are any weird values, but it actually does what is expected, which would be a suitable workaround for you right now (works for both cases provided). It would be good to get to the bottom of why this happens still though.

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import numpy as np

x = [-149.99, -143.82, -140.38, -140.40, -143.15, -147.54, -152.45, -156.84, -159.59, -159.61, -156.17, -149.99, -149.99]
y = [64.99, 64.07, 61.74, 58.93, 56.53, 55.17, 55.17, 56.53, 58.93, 61.74, 64.07, 64.99, 64.99]

fig = plt.figure(figsize=(8,8))
map_projection = ccrs.Orthographic(central_longitude=200,central_latitude=30)
p = map_projection.transform_points(
    ccrs.Geodetic(),
    np.array(x),
    np.array(y),
)
ax = plt.axes(projection = map_projection)
ax.plot(p[:, 0], p[:, 1], color='red', transform=map_projection)
ax.set_global()

plt.show()

@Swanson-Hysell
Copy link
Author

Swanson-Hysell commented Sep 27, 2018

Thanks for that workaround.

@QuLogic
Copy link
Member

QuLogic commented Sep 27, 2018

The "problem" is that your polygon is in the wrong order, i.e., the small portion is outside the polygon and most of the globe is inside. Another workaround is to reverse the order:

ax.set_global()
ax.plot(x[::-1], y[::-1], color='red', transform=ccrs.Geodetic())

That being said, I don't think plot should have such a limitation (or maybe should re-order for you) since it is not technically describing a polygon.

@Swanson-Hysell
Copy link
Author

Swanson-Hysell commented Sep 27, 2018

That is a nice compact workaround so is the one I will implement for now. Thanks.

@QuLogic
Copy link
Member

QuLogic commented Oct 7, 2018

Closing as duplicate of #1078.

@QuLogic QuLogic closed this as completed Oct 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@QuLogic @ajdawson @Swanson-Hysell

Footer

© 2024 GitHub, Inc.

深圳SEO优化公司SEO优化网站教程百度网站 优化怀化湖南网站优化推广金华优化网站报价神马网站排名优化粉天下网站优化湘潭网站建设优化网站优化应注意哪些静安区官网网站优化方案定制搜狗网站优化SEO网站栏目页优化技巧大连规模大的珠宝行业网站优化网站栏目页seo优化怎么做好优化网站排名斟酌易速达如何优化青岛网站夏邑专业网站优化怎么收费怎么优化电商网站阿里云网站建设及优化项城网站seo优化价格表海口网站关键词的优化网站优化首页付款静安区官网网站优化费用网站优化到期怎么续费遂宁德阳网站优化网站SEO优化费用网站主题模型优化方法怎么优化eso网站深圳官方网站优化费用多少网站搜索优化佳期易速达网站优化如何入手歼20紧急升空逼退外机英媒称团队夜以继日筹划王妃复出草木蔓发 春山在望成都发生巨响 当地回应60岁老人炒菠菜未焯水致肾病恶化男子涉嫌走私被判11年却一天牢没坐劳斯莱斯右转逼停直行车网传落水者说“没让你救”系谣言广东通报13岁男孩性侵女童不予立案贵州小伙回应在美国卖三蹦子火了淀粉肠小王子日销售额涨超10倍有个姐真把千机伞做出来了近3万元金手镯仅含足金十克呼北高速交通事故已致14人死亡杨洋拄拐现身医院国产伟哥去年销售近13亿男子给前妻转账 现任妻子起诉要回新基金只募集到26元还是员工自购男孩疑遭霸凌 家长讨说法被踢出群充个话费竟沦为间接洗钱工具新的一天从800个哈欠开始单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#中国投资客涌入日本东京买房两大学生合买彩票中奖一人不认账新加坡主帅:唯一目标击败中国队月嫂回应掌掴婴儿是在赶虫子19岁小伙救下5人后溺亡 多方发声清明节放假3天调休1天张家界的山上“长”满了韩国人?开封王婆为何火了主播靠辱骂母亲走红被批捕封号代拍被何赛飞拿着魔杖追着打阿根廷将发行1万与2万面值的纸币库克现身上海为江西彩礼“减负”的“试婚人”因自嘲式简历走红的教授更新简介殡仪馆花卉高于市场价3倍还重复用网友称在豆瓣酱里吃出老鼠头315晚会后胖东来又人满为患了网友建议重庆地铁不准乘客携带菜筐特朗普谈“凯特王妃P图照”罗斯否认插足凯特王妃婚姻青海通报栏杆断裂小学生跌落住进ICU恒大被罚41.75亿到底怎么缴湖南一县政协主席疑涉刑案被控制茶百道就改标签日期致歉王树国3次鞠躬告别西交大师生张立群任西安交通大学校长杨倩无缘巴黎奥运

深圳SEO优化公司 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化