cartopy
cartopy copied to clipboard
Scalebar
Issue #490
This Pull Requests closes #490
Rationale
In respect to the discussed in #490, here is an implementation of a scalebar for geoaxes.
The algorithm allows one to import the scalebar function directly from cartopy, or be directly called from the Goeaxes.
Implications
None applicable
Limitations:
So far, I have only been capable of inserting the scalebar without a background.
Here is an example for using it:
TODO:
Add some background for the scalebar
Code for generating the above examples:
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.scalebar import fancy_scalebar
def test_scalebar():
"""Test the scalebar"""
fig, axes = plt.subplots(1, 2,
subplot_kw={'projection':
ccrs.Mercator()})
projections = [ccrs.Mercator(), ccrs.PlateCarree()]
axes = axes.ravel()
try:
for proj, ax in zip(projections, axes):
ax.projection = proj
fancy_scalebar(ax,
location=(0.5, 0.2),
length=1000_000,
unit_name='km',
max_stripes=5,
fontsize=8,
dy=0.05)
ax.gridlines(draw_labels=True)
ax.stock_img()
ax.coastlines()
condition = True
except BaseException as err:
print(err)
condition = False
assert(condition)
def test_scalebar_within_geoaxes():
"""Test scalebat within the geoaxes"""
fig, axes = plt.subplots(1, 2,
subplot_kw={'projection':
ccrs.Mercator()})
projections = [ccrs.Mercator(),
ccrs.PlateCarree()]
axes = axes.ravel()
try:
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()
condition = True
except BaseException as err:
print(err)
condition = False
assert(condition)
if '__main__' == __name__:
test_scalebar()
test_scalebar_within_geoaxes()
Dear developers, now that the scalebar Issue is basically solved, should I close this Issue?
Sincerely,
Your code isn't merged in yet, so don't close any of the issues yet. If you put "closes #XX" with a link to the issue you want to close in your PR request it will automatically close the linked issues when someone merges the PR.
Dear @greglucas, thank you for the information. I have updated the body of this Pull Request adding the term: "closes #490". Therefore, I believe that once this Pull Request is merged, the Issue 490 will then be closed. Corret?
Sincerely,
Running PEP8 (or whatever formatter you used) on everything is very confusing, as it muddles what it is you actually changed here. You also seem to have mixed in your other PR here, so I really don't know what to look at.
Running PEP8 (or whatever formatter you used) on everything is very confusing, as it muddles what it is you actually changed here. You also seem to have mixed in your other PR here, so I really don't know what to look at.
@QuLogic, I have tried to clean all this confusion into this new commit. See if it helps.
Just want to add this is exactly the feature I am looking for! Need any help getting this merged?
Just want to add this is exactly the feature I am looking for! Need any help getting this merged?
Yes, please. I have done all I could do to facilitate the merge. Nevertheless, the time I updated this Pull Request, there were several LINT errors that would not allow a Merge. Therefore, I had to fix them all (even the ones that were not caused by this branch). As a consequence, it seems that this branch commit's history is now denser than the reviewers expected.
Let me know if I can be of any service.
Sincerely,
Any update on the progress with this? If not, is there something a complete beginner to this particular toolbox could do to move it along? Would love to see this feature implemented!
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.
:x: PhilipeRLeal
:x: adrien-berchet
You have signed the CLA already but the status is still pending? Let us recheck it.