matplotlib-map-utils 3.0.0__tar.gz → 3.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/PKG-INFO +7 -1
  2. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/README.md +6 -0
  3. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/core/scale_bar.py +16 -5
  4. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils.egg-info/PKG-INFO +7 -1
  5. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/pyproject.toml +1 -1
  6. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/LICENSE +0 -0
  7. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/__init__.py +0 -0
  8. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/core/__init__.py +0 -0
  9. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/core/inset_map.py +0 -0
  10. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/core/north_arrow.py +0 -0
  11. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/defaults/__init__.py +0 -0
  12. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/defaults/inset_map.py +0 -0
  13. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/defaults/north_arrow.py +0 -0
  14. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/defaults/scale_bar.py +0 -0
  15. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/scratch/map_utils.py +0 -0
  16. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/scratch/north_arrow_old_classes.py +0 -0
  17. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/utils/__init__.py +0 -0
  18. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/utils/usa.json +0 -0
  19. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/utils/usa.py +0 -0
  20. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/validation/__init__.py +0 -0
  21. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/validation/functions.py +0 -0
  22. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/validation/inset_map.py +0 -0
  23. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/validation/north_arrow.py +0 -0
  24. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils/validation/scale_bar.py +0 -0
  25. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils.egg-info/SOURCES.txt +0 -0
  26. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils.egg-info/dependency_links.txt +0 -0
  27. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils.egg-info/requires.txt +0 -0
  28. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/matplotlib_map_utils.egg-info/top_level.txt +0 -0
  29. {matplotlib_map_utils-3.0.0 → matplotlib_map_utils-3.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matplotlib-map-utils
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: A suite of tools for creating maps in matplotlib
5
5
  Author-email: David Moss <davidmoss1221@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/moss-xyz/matplotlib-map-utils/
@@ -211,6 +211,8 @@ There are two available styles for the scale bars: `boxes` and `ticks`. The quic
211
211
 
212
212
  ```python
213
213
  # Setting up a plot
214
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
215
+ # so that the scale_bar's DPI matches!
214
216
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
215
217
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
216
218
  # Here, this scale bar will have the "boxes" style
@@ -221,6 +223,8 @@ An object-oriented approach is also supported:
221
223
 
222
224
  ```python
223
225
  # Setting up a plot
226
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
227
+ # so that the scale_bar's DPI matches!
224
228
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
225
229
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
226
230
  # Here, we change the boxes to "ticks"
@@ -378,6 +382,8 @@ Two more projects assisted with the creation of this script:
378
382
 
379
383
  - `v3.0.0`: Release of inset map and extent and detail indicator classes and functions.
380
384
 
385
+ - `v3.0.1`: Fixed a bug that led to an incorrect Scale Bar being rendered when using the function method (`scale_bar()`) on a plot containing raster data (see [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/10) for details).
386
+
381
387
  #### Future Roadmap
382
388
 
383
389
  With the release of `v3.x`, this project has achieved full coverage of the "main" map elements I think are necessary.
@@ -192,6 +192,8 @@ There are two available styles for the scale bars: `boxes` and `ticks`. The quic
192
192
 
193
193
  ```python
194
194
  # Setting up a plot
195
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
196
+ # so that the scale_bar's DPI matches!
195
197
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
196
198
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
197
199
  # Here, this scale bar will have the "boxes" style
@@ -202,6 +204,8 @@ An object-oriented approach is also supported:
202
204
 
203
205
  ```python
204
206
  # Setting up a plot
207
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
208
+ # so that the scale_bar's DPI matches!
205
209
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
206
210
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
207
211
  # Here, we change the boxes to "ticks"
@@ -359,6 +363,8 @@ Two more projects assisted with the creation of this script:
359
363
 
360
364
  - `v3.0.0`: Release of inset map and extent and detail indicator classes and functions.
361
365
 
366
+ - `v3.0.1`: Fixed a bug that led to an incorrect Scale Bar being rendered when using the function method (`scale_bar()`) on a plot containing raster data (see [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/10) for details).
367
+
362
368
  #### Future Roadmap
363
369
 
364
370
  With the release of `v3.x`, this project has achieved full coverage of the "main" map elements I think are necessary.
@@ -280,6 +280,13 @@ def scale_bar(ax, draw=True, style: Literal["ticks","boxes"]="boxes",
280
280
  ##### CONFIG #####
281
281
 
282
282
  # Getting the config for the bar (length, text, divs, etc.)
283
+ if draw:
284
+ ax.get_figure().draw_without_rendering()
285
+
286
+ # window = ax.get_window_extent()
287
+ # tight = ax.patch.get_tightbbox()
288
+ # print(f"{draw} Window: width {round(window.width,2)} ({round(ax.get_figure().dpi_scale_trans.inverted().transform([window.width,0])[0],2)}), height {round(window.height,2)} ({round(ax.get_figure().dpi_scale_trans.inverted().transform([0,window.height])[1],2)})")
289
+ # print(f"{draw} Tight: width {round(tight.width,2)} ({round(ax.get_figure().dpi_scale_trans.inverted().transform([tight.width,0])[0],2)}), height {round(tight.height,2)} ({round(ax.get_figure().dpi_scale_trans.inverted().transform([0,tight.height])[1],2)})")
283
290
  bar_max, bar_length, units_label, major_div, minor_div = _config_bar(ax, _bar)
284
291
 
285
292
  # Getting the config for the segments (width, label, etc.)
@@ -452,7 +459,6 @@ def scale_bar(ax, draw=True, style: Literal["ticks","boxes"]="boxes",
452
459
 
453
460
  # AOB will contain the final artist
454
461
  aob_box = matplotlib.offsetbox.AnchoredOffsetbox(loc="center", child=major_pack, frameon=False, pad=0, borderpad=0)
455
-
456
462
  # Function that will handle invisibly rendering our object, returning an image
457
463
  img_scale_bar = _render_as_image(fig_temp, ax_temp, aob_box, _bar["rotation"])
458
464
 
@@ -641,6 +647,11 @@ def _config_bar(ax, bar):
641
647
  # Literally just getting the figure for the passed axis
642
648
 
643
649
  fig = ax.get_figure()
650
+ # fig.draw_without_rendering()
651
+ # Sets the canvas for the figure to AGG (Anti-Grain Geometry)
652
+ # canvas = FigureCanvasAgg(fig)
653
+ # Draws the figure onto the canvas
654
+ # canvas.draw()
644
655
 
645
656
  ## ROTATION ##
646
657
  # Calculating if the rotation is vertical or horizontal
@@ -651,15 +662,15 @@ def _config_bar(ax, bar):
651
662
  # Finding the max length and optimal divisions of the scale bar
652
663
 
653
664
  # Finding the dimensions of the axis and the limits
654
- # get_tightbbox() returns values in pixel coordinates
665
+ # get_window_extent() returns values in pixel coordinates
655
666
  # so dividing by dpi gets us the inches of the axis
656
667
  # Vertical scale bars are oriented against the y-axis (height)
657
668
  if bar_vertical==True:
658
- ax_dim = ax.patch.get_tightbbox().height / fig.dpi
669
+ ax_dim = ax.patch.get_window_extent().height / fig.dpi
659
670
  min_lim, max_lim = ax.get_ylim()
660
671
  # Horizontal scale bars are oriented against the x-axis (width)
661
672
  else:
662
- ax_dim = ax.patch.get_tightbbox().width / fig.dpi
673
+ ax_dim = ax.patch.get_window_extent().width / fig.dpi
663
674
  min_lim, max_lim = ax.get_xlim()
664
675
  # This calculates the range from max to min on the axis of interest
665
676
  ax_range = abs(max_lim - min_lim)
@@ -1011,7 +1022,7 @@ def _temp_figure(ax, axis=False, visible=False):
1011
1022
  # Getting the figure of the provided axis
1012
1023
  fig = ax.get_figure()
1013
1024
  # Getting the dimensions of the axis
1014
- ax_bbox = ax.patch.get_tightbbox()
1025
+ ax_bbox = ax.patch.get_window_extent()
1015
1026
  # Converting to inches and rounding up
1016
1027
  ax_dim = math.ceil(max(ax_bbox.height, ax_bbox.width) / fig.dpi)
1017
1028
  # Creating a new temporary figure
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matplotlib-map-utils
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: A suite of tools for creating maps in matplotlib
5
5
  Author-email: David Moss <davidmoss1221@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/moss-xyz/matplotlib-map-utils/
@@ -211,6 +211,8 @@ There are two available styles for the scale bars: `boxes` and `ticks`. The quic
211
211
 
212
212
  ```python
213
213
  # Setting up a plot
214
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
215
+ # so that the scale_bar's DPI matches!
214
216
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
215
217
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
216
218
  # Here, this scale bar will have the "boxes" style
@@ -221,6 +223,8 @@ An object-oriented approach is also supported:
221
223
 
222
224
  ```python
223
225
  # Setting up a plot
226
+ # NOTE: you MUST set the desired DPI here, when the subplots are created
227
+ # so that the scale_bar's DPI matches!
224
228
  fig, ax = matplotlib.pyplot.subplots(1,1, figsize=(5,5), dpi=150)
225
229
  # Adding a scale bar to the upper-right corner of the axis, in the same projection as whatever geodata you plotted
226
230
  # Here, we change the boxes to "ticks"
@@ -378,6 +382,8 @@ Two more projects assisted with the creation of this script:
378
382
 
379
383
  - `v3.0.0`: Release of inset map and extent and detail indicator classes and functions.
380
384
 
385
+ - `v3.0.1`: Fixed a bug that led to an incorrect Scale Bar being rendered when using the function method (`scale_bar()`) on a plot containing raster data (see [here](https://github.com/moss-xyz/matplotlib-map-utils/issues/10) for details).
386
+
381
387
  #### Future Roadmap
382
388
 
383
389
  With the release of `v3.x`, this project has achieved full coverage of the "main" map elements I think are necessary.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "matplotlib-map-utils"
7
- version = "3.0.0"
7
+ version = "3.0.1"
8
8
  authors = [
9
9
  { name="David Moss", email="davidmoss1221@gmail.com" },
10
10
  ]