ssb-sgis 1.2.2__tar.gz → 1.2.3__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.
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/PKG-INFO +1 -1
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/pyproject.toml +1 -1
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/general.py +1 -1
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/overlay.py +3 -1
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/explore.py +32 -35
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/legend.py +49 -43
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/map.py +117 -131
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/maps.py +2 -2
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/norge_i_bilder.json +410 -135
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/thematicmap.py +130 -47
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/wms.py +2 -1
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/raster/image_collection.py +12 -6
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/LICENSE +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/README.md +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/__init__.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/conf.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/debug_config.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/exceptions.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/__init__.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/bounds.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/centerlines.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/cleaning.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/conversion.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/duplicates.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/geocoding.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/geometry_types.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/neighbors.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/point_operations.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/polygon_operations.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/runners.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/sfilter.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/geopandas_tools/utils.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/helpers.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/io/__init__.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/io/_is_dapla.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/io/dapla_functions.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/io/opener.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/io/read_parquet.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/__init__.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/examine.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/httpserver.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/maps/tilesources.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/__init__.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/_get_route.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/_points.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/_service_area.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/closing_network_holes.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/cutting_lines.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/directednetwork.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/finding_isolated_networks.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/network.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/networkanalysis.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/networkanalysisrules.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/nodes.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/networkanalysis/traveling_salesman.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/parallel/__init__.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/parallel/parallel.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/py.typed +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/raster/__init__.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/raster/base.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/raster/indices.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/raster/regex.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/raster/sentinel_config.py +0 -0
- {ssb_sgis-1.2.2 → ssb_sgis-1.2.3}/src/sgis/raster/zonal.py +0 -0
|
@@ -172,9 +172,11 @@ def clean_overlay(
|
|
|
172
172
|
if df2.geometry.name != "geometry":
|
|
173
173
|
df2 = df2.rename_geometry("geometry")
|
|
174
174
|
|
|
175
|
-
# to pandas because GeoDataFrame constructor is
|
|
175
|
+
# to pandas because GeoDataFrame constructor is slow
|
|
176
176
|
df1 = DataFrame(df1).reset_index(drop=True)
|
|
177
177
|
df2 = DataFrame(df2).reset_index(drop=True)
|
|
178
|
+
df1.geometry.values.crs = None
|
|
179
|
+
df2.geometry.values.crs = None
|
|
178
180
|
|
|
179
181
|
overlayed = (
|
|
180
182
|
gpd.GeoDataFrame(
|
|
@@ -44,6 +44,7 @@ from ..geopandas_tools.general import make_all_singlepart
|
|
|
44
44
|
from ..geopandas_tools.geometry_types import get_geom_type
|
|
45
45
|
from ..geopandas_tools.geometry_types import to_single_geom_type
|
|
46
46
|
from ..helpers import _get_file_system
|
|
47
|
+
from ..helpers import dict_zip
|
|
47
48
|
from .wms import WmsLoader
|
|
48
49
|
|
|
49
50
|
try:
|
|
@@ -385,12 +386,12 @@ class Explore(Map):
|
|
|
385
386
|
|
|
386
387
|
super().__init__(column=column, show=show, **(new_kwargs | new_gdfs))
|
|
387
388
|
|
|
388
|
-
if self.
|
|
389
|
+
if self._gdfs is None:
|
|
389
390
|
return
|
|
390
391
|
|
|
391
392
|
# stringify or remove columns not renerable by leaflet (list, geometry etc.)
|
|
392
|
-
new_gdfs, show_new =
|
|
393
|
-
for gdf, show in
|
|
393
|
+
new_gdfs, show_new = {}, {}
|
|
394
|
+
for label, gdf, show in dict_zip(self._gdfs, self.show):
|
|
394
395
|
try:
|
|
395
396
|
gdf = gdf.reset_index()
|
|
396
397
|
except Exception:
|
|
@@ -420,18 +421,15 @@ class Explore(Map):
|
|
|
420
421
|
gdf.index = gdf.index.astype(str)
|
|
421
422
|
except Exception:
|
|
422
423
|
pass
|
|
423
|
-
new_gdfs
|
|
424
|
-
show_new
|
|
424
|
+
new_gdfs[label] = to_gdf(gdf)
|
|
425
|
+
show_new[label] = show
|
|
425
426
|
self._gdfs = new_gdfs
|
|
426
427
|
if self._gdfs:
|
|
427
428
|
self._gdf = pd.concat(new_gdfs, ignore_index=True)
|
|
428
429
|
else:
|
|
429
|
-
self._gdf =
|
|
430
|
+
self._gdf = self._get_gdf_template()
|
|
430
431
|
self.show = show_new
|
|
431
432
|
|
|
432
|
-
# if self._show_was_none and len(self._gdfs) > 6:
|
|
433
|
-
# self.show = [False] * len(self._gdfs)
|
|
434
|
-
|
|
435
433
|
if self._is_categorical:
|
|
436
434
|
if len(self.gdfs) == 1:
|
|
437
435
|
self._split_categories()
|
|
@@ -455,7 +453,7 @@ class Explore(Map):
|
|
|
455
453
|
rasters = self.raster_data
|
|
456
454
|
except AttributeError:
|
|
457
455
|
rasters = self.rasters
|
|
458
|
-
return len([gdf for gdf in self._gdfs if len(gdf)]) + len(rasters)
|
|
456
|
+
return len([gdf for gdf in self._gdfs.values() if len(gdf)]) + len(rasters)
|
|
459
457
|
|
|
460
458
|
def __bool__(self) -> bool:
|
|
461
459
|
"""True if any gdfs have rows or there are any raster images."""
|
|
@@ -473,7 +471,7 @@ class Explore(Map):
|
|
|
473
471
|
self.mask = mask if mask is not None else self.mask
|
|
474
472
|
if (
|
|
475
473
|
self._gdfs
|
|
476
|
-
and not any(len(gdf) for gdf in self._gdfs)
|
|
474
|
+
and not any(len(gdf) for gdf in self._gdfs.values())
|
|
477
475
|
and not len(self.rasters)
|
|
478
476
|
):
|
|
479
477
|
warnings.warn("None of the GeoDataFrames have rows.", stacklevel=1)
|
|
@@ -498,13 +496,11 @@ class Explore(Map):
|
|
|
498
496
|
else center
|
|
499
497
|
)
|
|
500
498
|
|
|
501
|
-
|
|
502
|
-
for gdf in self._gdfs:
|
|
499
|
+
for label, gdf in self._gdfs.items():
|
|
503
500
|
keep_geom_type = False if get_geom_type(gdf) == "mixed" else True
|
|
504
501
|
gdf = gdf.clip(centerpoint.buffer(size), keep_geom_type=keep_geom_type)
|
|
505
|
-
|
|
506
|
-
self._gdfs =
|
|
507
|
-
self._gdf = pd.concat(gdfs, ignore_index=True)
|
|
502
|
+
self._gdfs[label] = gdf
|
|
503
|
+
self._gdf = pd.concat(self._gdfs.values(), ignore_index=True)
|
|
508
504
|
|
|
509
505
|
self._get_unique_values()
|
|
510
506
|
|
|
@@ -558,19 +554,17 @@ class Explore(Map):
|
|
|
558
554
|
self._update_column()
|
|
559
555
|
kwargs.pop("column", None)
|
|
560
556
|
|
|
561
|
-
|
|
562
|
-
for gdf in self._gdfs:
|
|
557
|
+
for label, gdf in self._gdfs.items():
|
|
563
558
|
gdf = gdf.clip(self.mask)
|
|
564
559
|
collections = gdf.loc[gdf.geom_type == "GeometryCollection"]
|
|
565
560
|
if len(collections):
|
|
566
561
|
collections = make_all_singlepart(collections)
|
|
567
562
|
gdf = pd.concat([gdf, collections], ignore_index=False)
|
|
568
|
-
|
|
569
|
-
self._gdfs = gdfs
|
|
563
|
+
self._gdfs[label] = gdf
|
|
570
564
|
if self._gdfs:
|
|
571
|
-
self._gdf = pd.concat(self._gdfs, ignore_index=True)
|
|
565
|
+
self._gdf = pd.concat(self._gdfs.values(), ignore_index=True)
|
|
572
566
|
else:
|
|
573
|
-
self._gdf =
|
|
567
|
+
self._gdf = self._get_gdf_template()
|
|
574
568
|
|
|
575
569
|
self._explore(**kwargs)
|
|
576
570
|
|
|
@@ -638,8 +632,11 @@ class Explore(Map):
|
|
|
638
632
|
def _explore(self, **kwargs) -> None:
|
|
639
633
|
self.kwargs = self.kwargs | kwargs
|
|
640
634
|
|
|
641
|
-
if
|
|
642
|
-
self.
|
|
635
|
+
if (
|
|
636
|
+
self._show_was_none
|
|
637
|
+
and len([gdf for gdf in self._gdfs.values() if len(gdf)]) > 6
|
|
638
|
+
):
|
|
639
|
+
self.show = {label: False for label in self._gdfs}
|
|
643
640
|
|
|
644
641
|
if self._is_categorical:
|
|
645
642
|
self._create_categorical_map()
|
|
@@ -662,15 +659,13 @@ class Explore(Map):
|
|
|
662
659
|
display(self.map)
|
|
663
660
|
|
|
664
661
|
def _split_categories(self) -> None:
|
|
665
|
-
new_gdfs,
|
|
662
|
+
new_gdfs, new_shows = {}, {}
|
|
666
663
|
for cat in self._unique_values:
|
|
667
664
|
gdf = self.gdf.loc[self.gdf[self.column] == cat]
|
|
668
|
-
new_gdfs
|
|
669
|
-
|
|
670
|
-
new_shows.append(self.show[0])
|
|
665
|
+
new_gdfs[cat] = gdf
|
|
666
|
+
new_shows[cat] = next(iter(self.show.values()))
|
|
671
667
|
self._gdfs = new_gdfs
|
|
672
668
|
self._gdf = pd.concat(new_gdfs, ignore_index=True)
|
|
673
|
-
self.labels = new_labels
|
|
674
669
|
self.show = new_shows
|
|
675
670
|
|
|
676
671
|
def _to_single_geom_type(self, gdf: GeoDataFrame) -> GeoDataFrame:
|
|
@@ -720,12 +715,11 @@ class Explore(Map):
|
|
|
720
715
|
return gdf.total_bounds
|
|
721
716
|
|
|
722
717
|
def _create_categorical_map(self) -> None:
|
|
723
|
-
self.
|
|
718
|
+
self._prepare_categorical_plot()
|
|
724
719
|
if self._gdf is not None and len(self._gdf):
|
|
725
|
-
self._fix_nans()
|
|
726
720
|
gdf = self._prepare_gdf_for_map(self._gdf)
|
|
727
721
|
else:
|
|
728
|
-
gdf =
|
|
722
|
+
gdf = self._get_gdf_template()
|
|
729
723
|
|
|
730
724
|
self._load_rasters_as_images()
|
|
731
725
|
|
|
@@ -742,7 +736,7 @@ class Explore(Map):
|
|
|
742
736
|
**self.kwargs,
|
|
743
737
|
)
|
|
744
738
|
|
|
745
|
-
for
|
|
739
|
+
for label, gdf, show in dict_zip(self._gdfs, self.show):
|
|
746
740
|
if not len(gdf):
|
|
747
741
|
continue
|
|
748
742
|
|
|
@@ -798,7 +792,10 @@ class Explore(Map):
|
|
|
798
792
|
if self.scheme:
|
|
799
793
|
classified = self._classify_from_bins(self._gdf, bins=self.bins)
|
|
800
794
|
classified_sequential = self._push_classification(classified)
|
|
801
|
-
n_colors =
|
|
795
|
+
n_colors = (
|
|
796
|
+
len(np.unique(classified_sequential))
|
|
797
|
+
- self._gdf[self._column].isna().any()
|
|
798
|
+
)
|
|
802
799
|
unique_colors = self._get_continous_colors(n=n_colors)
|
|
803
800
|
|
|
804
801
|
self._load_rasters_as_images()
|
|
@@ -824,7 +821,7 @@ class Explore(Map):
|
|
|
824
821
|
index=self.bins,
|
|
825
822
|
)
|
|
826
823
|
|
|
827
|
-
for
|
|
824
|
+
for (label, gdf), show in zip(self._gdfs.items(), self.show, strict=True):
|
|
828
825
|
if not len(gdf):
|
|
829
826
|
continue
|
|
830
827
|
|
|
@@ -14,7 +14,7 @@ import matplotlib.pyplot as plt
|
|
|
14
14
|
import numpy as np
|
|
15
15
|
import pandas as pd
|
|
16
16
|
from geopandas import GeoDataFrame
|
|
17
|
-
from matplotlib.
|
|
17
|
+
from matplotlib.patches import Patch
|
|
18
18
|
from pandas import Series
|
|
19
19
|
|
|
20
20
|
from ..geopandas_tools.bounds import bounds_to_points
|
|
@@ -50,6 +50,7 @@ LEGEND_KWARGS = {
|
|
|
50
50
|
"rounding",
|
|
51
51
|
"facecolor",
|
|
52
52
|
"labelcolor",
|
|
53
|
+
"hatch",
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
LOWERCASE_WORDS = {
|
|
@@ -265,8 +266,17 @@ class Legend:
|
|
|
265
266
|
else:
|
|
266
267
|
self._markersize = size
|
|
267
268
|
|
|
269
|
+
def _get_patch(self, color, edgecolor="black", **kwargs) -> Patch:
|
|
270
|
+
return Patch(
|
|
271
|
+
facecolor=color,
|
|
272
|
+
edgecolor=edgecolor,
|
|
273
|
+
**kwargs,
|
|
274
|
+
)
|
|
275
|
+
|
|
268
276
|
def _prepare_categorical_legend(
|
|
269
|
-
self,
|
|
277
|
+
self,
|
|
278
|
+
categories_colors: dict,
|
|
279
|
+
hatch: str,
|
|
270
280
|
) -> None:
|
|
271
281
|
for attr in self.__dict__.keys():
|
|
272
282
|
if attr in self.kwargs:
|
|
@@ -279,31 +289,30 @@ class Legend:
|
|
|
279
289
|
}
|
|
280
290
|
# swap column values with label list and hope it's in the correct order
|
|
281
291
|
elif self.labels:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
self.labels, categories_colors.values(), strict=True
|
|
292
|
+
if len(self.labels) != len(categories_colors):
|
|
293
|
+
raise ValueError(
|
|
294
|
+
f"Unequal length of labels {self.labels} and categories/colors {categories_colors}"
|
|
286
295
|
)
|
|
287
|
-
|
|
296
|
+
categories_colors = dict(
|
|
297
|
+
zip(self.labels, categories_colors.values(), strict=True)
|
|
298
|
+
)
|
|
288
299
|
|
|
289
300
|
self._patches, self._categories = [], []
|
|
290
301
|
for category, color in categories_colors.items():
|
|
291
302
|
if self.pretty_labels:
|
|
292
303
|
category = prettify_label(category)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
304
|
+
self._categories.append(category)
|
|
305
|
+
self._patches.append(self._get_patch(color=color, hatch=hatch))
|
|
306
|
+
|
|
307
|
+
def _add_more_data_to_legend(self, more_data: dict[str, dict]) -> None:
|
|
308
|
+
for label, datadict in more_data.items():
|
|
309
|
+
if self.pretty_labels:
|
|
310
|
+
label = prettify_label(label)
|
|
311
|
+
self._categories.append(label)
|
|
312
|
+
datadict = {key: value for key, value in datadict.items() if key != "gdf"}
|
|
297
313
|
self._patches.append(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
[0],
|
|
301
|
-
linestyle="none",
|
|
302
|
-
marker="o",
|
|
303
|
-
alpha=self.kwargs.get("alpha", 1),
|
|
304
|
-
markersize=self._markersize,
|
|
305
|
-
markerfacecolor=color,
|
|
306
|
-
markeredgewidth=0,
|
|
314
|
+
self._get_patch(
|
|
315
|
+
**datadict,
|
|
307
316
|
)
|
|
308
317
|
)
|
|
309
318
|
|
|
@@ -595,40 +604,34 @@ class ContinousLegend(Legend):
|
|
|
595
604
|
self,
|
|
596
605
|
bins: list[float],
|
|
597
606
|
colors: list[str],
|
|
598
|
-
nan_label: str,
|
|
599
607
|
bin_values: dict,
|
|
608
|
+
nan_label: str,
|
|
609
|
+
hatch: str,
|
|
600
610
|
) -> None:
|
|
601
611
|
# TODO: clean up this messy method
|
|
602
612
|
|
|
603
|
-
|
|
613
|
+
if (
|
|
614
|
+
colors is not None
|
|
615
|
+
and self.labels is not None
|
|
616
|
+
and len(self.labels) != len(colors)
|
|
617
|
+
):
|
|
618
|
+
raise ValueError(
|
|
619
|
+
"Label list must be same length as the number of groups. "
|
|
620
|
+
f"Got k={len(colors)} and labels={len(self.labels)}."
|
|
621
|
+
f"labels: {', '.join(self.labels)}"
|
|
622
|
+
f"colors: {', '.join(colors)}"
|
|
623
|
+
f"bins: {bins}"
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
for attr in dict(self.kwargs):
|
|
604
627
|
if attr in self.__dict__:
|
|
605
628
|
self[attr] = self.kwargs.pop(attr)
|
|
606
629
|
|
|
607
630
|
self._patches, self._categories = [], []
|
|
608
|
-
|
|
609
631
|
for color in colors:
|
|
610
|
-
self._patches.append(
|
|
611
|
-
Line2D(
|
|
612
|
-
[0],
|
|
613
|
-
[0],
|
|
614
|
-
linestyle="none",
|
|
615
|
-
marker="o",
|
|
616
|
-
alpha=self.kwargs.get("alpha", 1),
|
|
617
|
-
markersize=self._markersize,
|
|
618
|
-
markerfacecolor=color,
|
|
619
|
-
markeredgewidth=0,
|
|
620
|
-
)
|
|
621
|
-
)
|
|
632
|
+
self._patches.append(self._get_patch(color=color, hatch=hatch))
|
|
622
633
|
|
|
623
634
|
if self.labels:
|
|
624
|
-
if len(self.labels) != len(colors):
|
|
625
|
-
raise ValueError(
|
|
626
|
-
"Label list must be same length as the number of groups. "
|
|
627
|
-
f"Got k={len(colors)} and labels={len(self.labels)}."
|
|
628
|
-
f"labels: {', '.join(self.labels)}"
|
|
629
|
-
f"colors: {', '.join(colors)}"
|
|
630
|
-
f"bins: {bins}"
|
|
631
|
-
)
|
|
632
635
|
self._categories = self.labels
|
|
633
636
|
|
|
634
637
|
elif len(bins) == len(colors):
|
|
@@ -703,6 +706,9 @@ class ContinousLegend(Legend):
|
|
|
703
706
|
label = self._get_two_value_label(min_rounded, max_rounded)
|
|
704
707
|
self._categories.append(label)
|
|
705
708
|
|
|
709
|
+
# if nan_label:
|
|
710
|
+
# self._categories.append(nan_label)
|
|
711
|
+
|
|
706
712
|
def _get_two_value_label(self, value1: int | float, value2: int | float) -> str:
|
|
707
713
|
return (
|
|
708
714
|
f"{value1} {self.label_suffix} {self.label_sep} "
|