Skip to content

Conversation

@overeem11
Copy link

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks from pre-commit passed
  • Added an entry in the CHANGELOG.md file

@cchwala
Copy link
Member

cchwala commented Sep 24, 2025

Here is the code that I used to check if and how LineCollection works togeter with cartopy projection and transformation.

import numpy as np
import cartopy.crs as ccrs

colors = ["indigo", "blue", "green", "yellow", "orange", "red"]

# create a list of half-circles with varying radii
theta = np.linspace(0, np.pi, 36)
radii = np.linspace(4, 5, num=len(colors))
arcs = [np.column_stack([r * np.cos(theta), r * np.sin(theta)]) for r in radii]

ax = plt.axes(projection=ccrs.Geostationary(0))
ax.stock_img()
#ax = plt.axes()
# set axes limits manually because Collections do not take part in autoscaling
#ax.set_xlim(-80, 180)
#ax.set_ylim(-90, 90)
#ax.set_aspect("equal")  # to make the arcs look circular

# create a LineCollection with the half-circles
# its properties can be set per line by passing a sequence (here used for *colors*)
# or they can be set for all lines by passing a scalar (here used for *linewidths*)

line_collection = LineCollection(arcs, colors=colors, linewidths=4, transform=ccrs.PlateCarree())
ax.add_collection(line_collection)

which creates the following image

Bildschirmfoto 2025-09-24 um 14 01 52

This code is a combination of the LineCollection example in the matplotlib docs and an example from the cartopy docs. As discussed offline, it looks as if the transform kwarg is consumed by LineCollection (according to what we saw when changing to different source projection).

@cchwala
Copy link
Member

cchwala commented Oct 10, 2025

@overeem11 I had a go at integrating some parts of what you have in the separate scatter_lines_background() into the standard scatter_lines() so that plot_lines() does not have to distinguish between the two. Not all features are there, but at least it works now for plotting lines with map background, see the WIP notebook here and the screenshot below.

Bildschirmfoto 2025-10-10 um 09 44 45

Remaining TODOs:

  • allow flexible configuration of NE maps (coastlines, boarders, etc...) which could IMO be best be done with a default dict that is passed as argument and which has the default values that can be adjusted if needed.
  • add same functionality (mainly via the new set_up_axes() helper function) to plot_plg() so that we can also plot the maps as background when plotting points and grids in the same way
  • add same functionality to xarray accessor ploting function

@overeem11 What are crucial feature that are missing in you opinion?

…ebook

I did also refactor the exiting things a bit. This is not perfect yet, though.
Maybe a better solution would be to completely remove the map background stuff
from plot_lines and only have it in plot_plg because plot_lines could be a function
that is not exposed to the user anyway since plot_plg has the same functionality
plus the option to plot grid and points in addition...
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 35.18519% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.87%. Comparing base (627dd69) to head (1cc5c12).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/poligrain/plot_map.py 35.18% 35 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #107      +/-   ##
==========================================
- Coverage   98.75%   94.87%   -3.89%     
==========================================
  Files           7        7              
  Lines         723      858     +135     
==========================================
+ Hits          714      814     +100     
- Misses          9       44      +35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cchwala
Copy link
Member

cchwala commented Oct 14, 2025

Current status:

  • formating okay
  • old test pass, except for python 3.9

TODOs:

  • add tests
  • clean up notebook
  • maybe implement the remaining features mentioned as TODO above

I will take a break with this PR and try to finish it next week.

this is also the current state in upstream/main but I add it here manually
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

Successfully merging this pull request may close these issues.

2 participants