conda-forge / cartopy-feedstock

A conda-smithy repository for cartopy.
BSD 3-Clause "New" or "Revised" License
4 stars 16 forks source link

Cann't change "linewidth" when adding geometries. #39

Closed gepcel closed 7 years ago

gepcel commented 7 years ago

There's a mismatch file between cartopy of conda-forge and cartopy from master repository.

There is a Line 111 in file Lib/site-packages/cartopy/mpl/feature_artist.py :

100        self.set_zorder(1)
111  self._kwargs.setdefault('linewidth', 1.0)
113  self._feature = feature

Which caused an issue that when ax.add_geometries(..., linewidth=0.5), the 'linewidth' arg doesn't work. An example code might be like:

%matplotlib inline
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader
import cartopy.io.shapereader as shpreader

shpfilename = shpreader.natural_earth(resolution='110m',
                                      category='cultural',
                                      name='admin_0_countries')
shp = Reader(shpfilename)
fig, [ax1, ax2] = plt.subplots(1, 2, figsize=(8,3),
                               subplot_kw={'projection': ccrs.PlateCarree()})
ax1.add_geometries(shp.geometries(), crs=ccrs.PlateCarree(),
                 linewidth=0.1, edgecolor='k')
ax1.set(title='linewidth = 0.1')
ax2.add_geometries(shp.geometries(), crs=ccrs.PlateCarree(),
                 linewidth=10, edgecolor='k')
ax2.set(title='linewidth = 10')
plt.tight_layout()
plt.show()

The result would be:

As the line of code, I don't quite understand, because it seems to only to set linewidth to 1.0 if linewidth is not specified. Not sure what's wrong. I've filed an issue at cartopy.

os: windows 10 x64 python: 3.6.2 cartopy: 0.15.1 matplotlib: 2.0.2 conda: 4.3.27

ocefpaf commented 7 years ago

@dopplershift I believe that is related to the patch you ported, correct? Can you take a look?

gepcel commented 7 years ago

OK, I pulled a request #40 . I filed an issue first mainly because:

  1. I don't understand why that line of code will make the linewidth unchangable. I suppose that will only make the linewidth default to 1.0, if no arg given.
  2. Since there's no this line in the cartopy master repository, I'm not sure if there are other reasons of adding that line. So I want to ask first.
gepcel commented 7 years ago

Closed by #40 #