newsworthycharts 1.74.1__py3-none-any.whl → 1.75.0__py3-none-any.whl

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.
@@ -1,4 +1,4 @@
1
- __version__ = "1.74.1"
1
+ __version__ = "1.75.0"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
@@ -33,6 +33,10 @@ class ChoroplethMap(Map):
33
33
 
34
34
  df = self._prepare_map_data()
35
35
 
36
+ missing_color = "gainsboro"
37
+ if self.missing_color:
38
+ missing_color = self.missing_color
39
+
36
40
  args = {
37
41
  "categorical": True,
38
42
  "legend": True, # bug in geopandas, fixed in master but not released
@@ -43,7 +47,7 @@ class ChoroplethMap(Map):
43
47
  "edgecolor": "white",
44
48
  "linewidth": 0.2,
45
49
  "missing_kwds": {
46
- "color": "gainsboro",
50
+ "color": missing_color,
47
51
  },
48
52
  }
49
53
  # This should be adjusted per basemap
@@ -58,8 +62,8 @@ class ChoroplethMap(Map):
58
62
  # normalize the data ourselves, otherwise the inset maps will be off
59
63
  norm = mpl.colors.Normalize(vmin=df["data"].min(), vmax=df["data"].max())
60
64
  mapper = mpl.cm.ScalarMappable(norm=norm, cmap=self.color_ramp)
61
- df["color"] = df["data"].apply(lambda x: mapper.to_rgba(x) if not np.isnan(x) else "gainsboro")
62
- df["color"] = df["color"].fillna("gainsboro")
65
+ df["color"] = df["data"].apply(lambda x: mapper.to_rgba(x) if not np.isnan(x) else missing_color)
66
+ df["color"] = df["color"].fillna(missing_color)
63
67
  args["color"] = df["color"]
64
68
 
65
69
  self._fig.tight_layout()
@@ -129,8 +133,8 @@ class ChoroplethMap(Map):
129
133
  # normalize the data ourselves, otherwise the inset maps will be off
130
134
  norm = mpl.colors.Normalize(vmin=_has_value["data"].min(), vmax=_has_value["data"].max())
131
135
  mapper = mpl.cm.ScalarMappable(norm=norm, cmap=self.color_ramp)
132
- df["color"] = df["data"].apply(lambda x: mapper.to_rgba(x) if not np.isnan(x) else "gainsboro")
133
- df["color"] = df["color"].fillna("gainsboro")
136
+ df["color"] = df["data"].apply(lambda x: mapper.to_rgba(x) if not np.isnan(x) else missing_color)
137
+ df["color"] = df["color"].fillna(missing_color)
134
138
  args["color"] = df["color"]
135
139
 
136
140
  # Add labels legend (manually, Geopandas is too crude as of now)
@@ -173,7 +177,7 @@ class ChoroplethMap(Map):
173
177
  for idx, cat in enumerate(cat):
174
178
  color_map[cat] = self._nwc_style["qualitative_colors"][idx]
175
179
  df["color"] = df["data"].astype(str).map(color_map)
176
- df["color"] = df["color"].fillna("gainsboro")
180
+ df["color"] = df["color"].fillna(missing_color)
177
181
  args["color"] = df["color"]
178
182
 
179
183
  # Geopandas does not handle legend if color keyword is used
@@ -195,7 +199,7 @@ class ChoroplethMap(Map):
195
199
  patches.append(patch)
196
200
  patches = list(reversed(patches))
197
201
  if self.missing_label and len(patches):
198
- patches.append(mpatches.Patch(color="gainsboro", label=self.missing_label))
202
+ patches.append(mpatches.Patch(color=missing_color, label=self.missing_label))
199
203
 
200
204
  df.plot(ax=self.ax, **args)
201
205
  # Add outer edge
newsworthycharts/map.py CHANGED
@@ -94,6 +94,7 @@ class Map(Chart):
94
94
  self.categorical = kwargs.get("categorical", False)
95
95
  self.base_map = None
96
96
  self.missing_label = None
97
+ self.missing_color = None
97
98
  self.df = None
98
99
  self.show_ticks = False
99
100
 
@@ -539,7 +539,10 @@ class SerialChart(Chart):
539
539
  (x0, x1) = self.highlighted_x_ranges[idx]
540
540
  x0 = to_date(x0)
541
541
  x1 = to_date(x1)
542
+ # Put label betwen top value and axis limit
542
543
  _y = self.ymax or self.data.max_val + self.baseline
544
+ _y_top = self.ax.get_ylim()[1]
545
+ _y = _y_top - (_y_top - _y) / 2
543
546
  self.ax.text(
544
547
  x0 + (x1 - x0) / 2,
545
548
  _y,
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: newsworthycharts
3
- Version: 1.74.1
3
+ Version: 1.75.0
4
4
  Summary: Matplotlib wrapper to create charts and publish them on Amazon S3
5
5
  Home-page: https://github.com/jplusplus/newsworthycharts
6
- Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.74.1.tar.gz
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.75.0.tar.gz
7
7
  Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
8
8
  Author-email: stockholm@jplusplus.org
9
9
  License: MIT
@@ -21,7 +21,7 @@ Requires-Dist: python-dateutil<3,>=2
21
21
  Requires-Dist: Pillow==11.2.1
22
22
  Requires-Dist: requests>=2.22
23
23
  Requires-Dist: matplotlib-label-lines==0.5.1
24
- Requires-Dist: geopandas==1.0.1
24
+ Requires-Dist: geopandas==1.1.0
25
25
  Requires-Dist: mapclassify==2.8.1
26
26
  Dynamic: author
27
27
  Dynamic: author-email
@@ -225,6 +225,7 @@ These settings are available for all chart types:
225
225
  - `categorical` = False # If True, the map will be colored by category. If False, it will be colored by a continuous value
226
226
  - `base_map` = None
227
227
  - `missing_label` = None # Add a label for no data
228
+ - `missing_color` = "gainsboro" # Color for regions with no data
228
229
 
229
230
  `basemap` can be `{ISO}-{level}` or `{ISO}|{subset}-{level}`.
230
231
  For example, `se-4` will show Swedish counties, while `se|03-7` will show municipalities (`se-7`) starting with `03`.
@@ -285,6 +286,15 @@ Roadmap
285
286
  Changelog
286
287
  ---------
287
288
 
289
+ - 1.75.0
290
+
291
+ - geopandas==1.1.0
292
+ - Added `missing_color` argument to ChoroplethMap, to set the color of regions with no data
293
+
294
+ - 1.74.2
295
+
296
+ - Improved positioning of x-range annotations in SerialChart
297
+
288
298
  - 1.74.1
289
299
 
290
300
  - Wait for data to be added before calculating dynamic heights and responsive typography
@@ -1,15 +1,15 @@
1
- newsworthycharts/__init__.py,sha256=fRJO8g3nfstntB5oDDv7d411O48Z4OkA-eL5IvwTRaY,1221
1
+ newsworthycharts/__init__.py,sha256=s4ey1U5ZXaKsuTS3HiWnmpfA8QwY-m28T4XFqgAO1gc,1221
2
2
  newsworthycharts/bubblemap.py,sha256=nkocWmpiFgfjEuJGAsthjY5X7Q56jXWsZHUGXw4PwgE,2587
3
3
  newsworthycharts/categoricalchart.py,sha256=Vr-0yFms0hEVCeUa3vLt3FYBqpX4xLQ8YGPc4LGQN_A,18368
4
4
  newsworthycharts/chart.py,sha256=QDvIo_HV9fDmadBKLsPJMXrIYL6ZbHnDbVjZuzX9Srw,35441
5
- newsworthycharts/choroplethmap.py,sha256=eJiFcUpPFnkiF8VPiHTROdMuuRXHNX8_65rdowBskpc,9709
5
+ newsworthycharts/choroplethmap.py,sha256=a31tavi8lSVhzYierf2exuO32moGXVKHYbTYV0sFL1U,9838
6
6
  newsworthycharts/datawrapper.py,sha256=RRkAVTpfP4updKxUIBaSmKuBi2RUVPaBRF8HDQhlGGA,11250
7
- newsworthycharts/map.py,sha256=EGh96tU10y7Kgu1e83_VWQSeABdjP6V-0VM6VTHDxu4,6089
7
+ newsworthycharts/map.py,sha256=tECE7bZhJnvJxFV2pSitDxaHrKOwjBjoSA15H-MdzeI,6123
8
8
  newsworthycharts/rangeplot.py,sha256=NE1W9TnmlpK6T3RvBJOU3nd73EXqkj17OY9i5zlw_cQ,8366
9
9
  newsworthycharts/rankchart.py,sha256=vMzNMVOv1jae6wuHC_riAdb1lm9oPltO3TT3YQpc0Oc,9376
10
10
  newsworthycharts/scatterplot.py,sha256=weHubdMsDGaBTXejg2TqBNPTQ1K-QBpZqJiyQ8EOEc4,5084
11
11
  newsworthycharts/seasonalchart.py,sha256=ttT8JpvWB3DL0EcTBQor_Uxlow_6tdcl7ibEmLCpUrQ,1982
12
- newsworthycharts/serialchart.py,sha256=Km1qxTumFq0GcKPzdaaU5mhq9f2BtusQ0tbpW6WsMiw,31936
12
+ newsworthycharts/serialchart.py,sha256=0soPp2hwCYNOv1c8iTBCkh6YwXlhTDqZlR5j4k3uh3Q,32079
13
13
  newsworthycharts/storage.py,sha256=myERhlpvXyExXxUByBq9eW1bWkCyfH9SwTZbsWSyy3Q,4301
14
14
  newsworthycharts/stripechart.py,sha256=9B6PX2MyLuKNQ8W0OGdKbP0-U32kju0K_NHHwwz_J68,1547
15
15
  newsworthycharts/custom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -29,8 +29,8 @@ newsworthycharts/rc/newsworthy,sha256=yOIZvYS6PG1u19VMcdtfj9vbihKQsey5IprwqK59Kg
29
29
  newsworthycharts/translations/datawrapper_regions.csv,sha256=fzZcQRX6RFMlNNP8mpgfYNdR3Y0QAlQxDXk8FXTaWWI,9214
30
30
  newsworthycharts/translations/regions.py,sha256=Nv1McQjggD4S3JRu82rDMTG3pqUVR13E5-FBpSYbm98,239
31
31
  newsworthycharts/translations/se_municipalities.csv,sha256=br_mm-IvzQtj_W55_ATREhJ97jWnCweBFlDAVY2EBxA,7098
32
- newsworthycharts-1.74.1.dist-info/licenses/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
- newsworthycharts-1.74.1.dist-info/METADATA,sha256=4VzONRQwYL2m336k48UXCPBNt29KTv-1rtVhMwWA6P8,35284
34
- newsworthycharts-1.74.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
35
- newsworthycharts-1.74.1.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
- newsworthycharts-1.74.1.dist-info/RECORD,,
32
+ newsworthycharts-1.75.0.dist-info/licenses/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
+ newsworthycharts-1.75.0.dist-info/METADATA,sha256=8A7ATOaIxGnOm2tz2nGGN8ViEYoz3S7pt6GXwFWDG5E,35550
34
+ newsworthycharts-1.75.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
35
+ newsworthycharts-1.75.0.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
+ newsworthycharts-1.75.0.dist-info/RECORD,,