Skip to content
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.

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

Scalebar #1728

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f591656
first commit of the branch solely_scalebar. In this first comit, the …
PhilipeRLeal Dec 22, 2020
2f9bd86
scalebar_usage_examples.py has been updated in accordance to pep8 sta…
PhilipeRLeal Dec 22, 2020
abdb826
small changes in the comments from the scalebar_example
PhilipeRLeal Dec 22, 2020
c6e5343
This is a merge of the prior developers git branch and the new functi…
adrien-berchet Jul 16, 2020
88fadae
changes in the cartopy.mpl.gridliner class. It has methods for easily…
PhilipeRLeal Dec 16, 2020
37b9e11
There were changes in the LOGITUDE_FORMATTER and the LATITUDE_FORMATT…
PhilipeRLeal Dec 16, 2020
bd4779d
scalebar has been added, as well as its test suit
PhilipeRLeal Dec 16, 2020
d24b2d6
contributor list has been updated
PhilipeRLeal Dec 16, 2020
256fa6c
requirements documentation has been updated
PhilipeRLeal Dec 16, 2020
db2719d
an example of the scalebar functionality has been added
PhilipeRLeal Dec 16, 2020
2aad573
importation of the formatter module has been fixed
PhilipeRLeal Dec 16, 2020
720276a
formatters.py, gridliner.py, scalebar.py and scalebar_example.py have…
PhilipeRLeal Dec 16, 2020
6827366
changes to the scalebar_example.py
PhilipeRLeal Dec 16, 2020
01a0d78
the geopy requirement is no longer needed. Scalebar module is running ok
PhilipeRLeal Dec 16, 2020
c2f0cf6
scalebar example has been updated
PhilipeRLeal Dec 16, 2020
bbd68ea
the package can now create a scalebar for practically any cartopy's p…
PhilipeRLeal Dec 16, 2020
3f3b231
test suit for scalebar has been updated
PhilipeRLeal Dec 16, 2020
21b7d36
test suit has been updated
PhilipeRLeal Dec 16, 2020
6510719
scalebar can now be called directly from the geoaxes. Also, the test …
PhilipeRLeal Dec 17, 2020
170c2ca
The lib has been updated in accordance to PEP8 format. Besides, the s…
PhilipeRLeal Dec 17, 2020
e24e906
test_scalebar has been updated
PhilipeRLeal Dec 21, 2020
ee9a20b
formatters, scalebar and test_scalebar modules have had their copyrig…
PhilipeRLeal Dec 21, 2020
c34048a
There were changes in the formatter.py, gridliner.py, and the respect…
PhilipeRLeal Dec 22, 2020
c459a8b
first commit of the gridline ticklabel branch
PhilipeRLeal Dec 22, 2020
944f121
griliner test has been updated
PhilipeRLeal Dec 22, 2020
10dea03
there were updates in the LicenseHeaders of the tests and the example…
PhilipeRLeal Dec 22, 2020
8d18292
test_gridliner.py has been updated. Now, error messages are returned …
PhilipeRLeal Dec 27, 2020
55409e8
small changes in variables given long name problems from PEP8
PhilipeRLeal Dec 27, 2020
2129820
both branches have been properly merged. COnflict merging has been so…
PhilipeRLeal Jan 21, 2021
a15a7fc
The scalebar is now inserted to the geoaxes through the matplotlib's …
PhilipeRLeal Feb 2, 2021
403bee9
the scalebar test module has been updated
PhilipeRLeal Feb 2, 2021
3413f4e
stickler problems were solved
PhilipeRLeal Feb 2, 2021
609bde8
Merge branch 'scalebar' into master
PhilipeRLeal Feb 2, 2021
fd4d158
test_scalebar.py has been updated. The test was not passing beforehand
PhilipeRLeal Feb 3, 2021
aba434d
stickler hsa been solved
PhilipeRLeal Feb 3, 2021
80a0791
Update test_scalebar.py
PhilipeRLeal Feb 3, 2021
4d81ab3
Update test_scalebar.py
PhilipeRLeal Feb 3, 2021
2eef209
Merge branch 'master' of https://github.com/PhilipeRLeal/cartopy into…
PhilipeRLeal Feb 3, 2021
d9ea1ca
Merge branch 'solely_scalebar' of https://github.com/PhilipeRLeal/car…
PhilipeRLeal Feb 3, 2021
4ff5f8e
Merge branch 'master' into scalebar
PhilipeRLeal Feb 3, 2021
848aec4
scalebar is running OK. It can be plotted against several projections
PhilipeRLeal Feb 5, 2021
a2c3124
small updates in the ruler unit font formatter
PhilipeRLeal Feb 5, 2021
9d0c19e
PEP8 standardized
PhilipeRLeal Feb 5, 2021
2d2a8bd
Update test_scalebar.py
PhilipeRLeal Feb 6, 2021
a43ad7d
Create test_scalebar.py
PhilipeRLeal Feb 6, 2021
647982f
Update test_scalebar.py
PhilipeRLeal Feb 6, 2021
44b15a0
Update test_scalebar.py
PhilipeRLeal Feb 6, 2021
6dbb58b
Update scalebar.py
PhilipeRLeal May 7, 2021
2347fe3
Merge branch 'master' into scalebar
PhilipeRLeal Jul 8, 2021
4e98ac5
lint errors solved
PhilipeRLeal Aug 7, 2021
c3f04b0
Merge branch 'master' into scalebar
PhilipeRLeal Aug 7, 2021
a725517
Merge branch 'master' into scalebar
PhilipeRLeal Aug 10, 2021
35deefa
Merge branch 'master' into scalebar
PhilipeRLeal Sep 15, 2021
dd11be7
Update scalebar.py
PhilipeRLeal Sep 15, 2021
6f6ecb8
Update scalebar.py
PhilipeRLeal Sep 15, 2021
452c07e
Update scalebar.py
PhilipeRLeal Sep 15, 2021
e76ad0c
Update scalebar.py
PhilipeRLeal Sep 15, 2021
77633c5
Update test_gridliner.py
PhilipeRLeal Sep 15, 2021
e23e5c9
Update test_gridliner.py
PhilipeRLeal Sep 15, 2021
ada512d
Update scalebar.py
PhilipeRLeal Sep 15, 2021
2db0b83
Update scalebar.py
PhilipeRLeal Sep 15, 2021
3089d7b
Update test_gridliner.py
PhilipeRLeal Sep 15, 2021
017e709
Update gridliner.py
PhilipeRLeal Sep 15, 2021
2efb350
Delete gridliner.py
PhilipeRLeal Sep 15, 2021
a5f26f6
Create gridliner.py
PhilipeRLeal Sep 15, 2021
c421933
Delete formatters.py
PhilipeRLeal Sep 15, 2021
1a4d10a
Update gridliner.py
PhilipeRLeal Sep 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ the package wouldn't be as rich or diverse as it is today:
* Greg Lucas
* Sadie Bartholomew
* Kacper Makuch
* Philipe Riskalla Leal

Thank you!

Expand Down
78 changes: 77 additions & 1 deletion examples/gridlines_and_labels/gridliner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Copyright Cartopy Contributors
#
# This file is part of Cartopy and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.


"""
Gridlines and tick labels
-------------------------
Expand Down Expand Up @@ -44,6 +51,75 @@ def main():
gl.right_labels = False
plt.show()

plt.figure(figsize=(7, 3))
ax3 = plt.axes(projection=ccrs.PlateCarree())
ax3.set_extent([-65, -40, -15, 10])

# Create a feature for States/Admin 1 regions at 1:50m from Natural Earth
states_provinces = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_1_states_provinces_lines',
scale='50m',
facecolor='none')
ax3.add_feature(states_provinces, edgecolor='gray')

ax3.coastlines(resolution='110m')
ax3.coastlines(resolution='110m')
gl = ax3.gridlines(draw_labels=True)

gl.change_gridline_tick_decimal_separator('{0:.3f}',
axis='both')

gl.set_latitude_hemisphere_str('Norte', 'Sul')

gl.set_longitude_hemisphere_str('O', 'L')

gl.top_labels = False
gl.right_labels = False
plt.show()

return plt.gcf().get_axes(), gl


def gridliner_with_custom_changes_in_its_ticklabels():

import cartopy.feature as cfeature
plt.figure(figsize=(7, 3))
ax3 = plt.axes(projection=ccrs.PlateCarree())
ax3.set_extent([-65, 40, -15, 10])

# Create a feature for States/Admin 1 regions at 1:50m from Natural Earth
states_provinces = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_1_states_provinces_lines',
scale='50m',
facecolor='none')
ax3.add_feature(states_provinces, edgecolor='gray')

ax3.coastlines(resolution='110m')
ax3.coastlines(resolution='110m')
gl = ax3.gridlines(draw_labels=True)

gl.change_gridline_tick_decimal_separator('{0:.2f}',
axis='both',
decimal_separator=',')

gl.set_latitude_hemisphere_str(' - Norte', ' - Sul')

gl.set_longitude_hemisphere_str('Oeste', 'Leste')

gl.top_labels = False
gl.right_labels = False
plt.show()
plt.close('all')


if __name__ == '__main__':
main()

gridliner_with_custom_changes_in_its_ticklabels()

axes, gl = main()

print('N° of axes ', len(axes))

ax = axes[0]
1 change: 1 addition & 0 deletions examples/miscellanea/favicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np



def main():
fig = plt.figure(figsize=[8, 8])
ax = fig.add_subplot(1, 1, 1, projection=ccrs.SouthPolarStereo())
Expand Down
61 changes: 61 additions & 0 deletions examples/scalebar/scalebar_usage_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright Cartopy Contributors
#
# This file is part of Cartopy and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.scalebar import fancy_scalebar


def scalebar_invoqued_as_an_independent_object_geoaxes():

fig, axes = plt.subplots(1, 2,
subplot_kw={'projection':
ccrs.Mercator()})

projections = [ccrs.Mercator(), ccrs.PlateCarree()]

axes = axes.ravel()

for proj, ax in zip(projections, axes):
ax.projection = proj
fancy_scalebar(ax,
location=(0.5, 0.2),
length=1000_000,
unit_name='km',
angle=0,
max_stripes=5,
fontsize=8,
dy=0.05)

ax.gridlines(draw_labels=True)
ax.stock_img()
ax.coastlines()


def scalebar_from_within_geoaxes():

fig, axes = plt.subplots(1, 2,
subplot_kw={'projection':
ccrs.Mercator()})

projections = [ccrs.Mercator(),
ccrs.PlateCarree()]

axes = axes.ravel()

for proj, ax in zip(projections, axes):
ax.projection = proj

ax.set_extent([-60, -35, -40, 10])
ax.gridlines(draw_labels=True)
ax.add_scalebar(location=(0.5, 0.5),
length=250_000,
dy=5,
max_stripes=3)
ax.stock_img()
ax.coastlines()

fig.show()
11 changes: 7 additions & 4 deletions lib/cartopy/mpl/clip_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ def intersection_point(p0, p1, p2, p3):
raise ValueError('Lines are parallel and cannot '
'intersect at any one point.')

x = ((x_1 * y_2 - y_1 * x_2) * (x_3 - x_4) - (x_1 - x_2) * (x_3 *
y_4 - y_3 * x_4)) / div
y = ((x_1 * y_2 - y_1 * x_2) * (y_3 - y_4) - (y_1 - y_2) * (x_3 *
y_4 - y_3 * x_4)) / div
x = ((x_1 * y_2 - y_1 * x_2) *
(x_3 - x_4) - (x_1 - x_2) * (x_3 * y_4 - y_3 * x_4)
) / div

y = ((x_1 * y_2 - y_1 * x_2) * (y_3 - y_4) -
(y_1 - y_2) * (x_3 * y_4 - y_3 * x_4)
) / div

return x, y

Expand Down
1 change: 1 addition & 0 deletions lib/cartopy/mpl/feature_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class _GeomKey:
A workaround for Shapely polygons no longer being hashable as of 1.5.13.

"""

def __init__(self, geom):
self._id = id(geom)

Expand Down
Loading