newsworthycharts 1.56.0__py3-none-any.whl → 1.57.1__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.56.0"
1
+ __version__ = "1.57.1"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
@@ -23,7 +23,6 @@ class BubbleMap(Map):
23
23
  def __init__(self, *args, **kwargs):
24
24
  super(BubbleMap, self).__init__(*args, **kwargs)
25
25
  self.bubble_size = kwargs.get("bubble_size", 1)
26
- print(self.bubble_size)
27
26
 
28
27
  def _add_data(self):
29
28
 
newsworthycharts/chart.py CHANGED
@@ -432,16 +432,6 @@ class Chart(object):
432
432
  if len(self.data):
433
433
  self._add_data()
434
434
 
435
- if (self.yline):
436
- self.ax.axhline(
437
- y=self.yline,
438
- color=self._nwc_style["neutral_color"],
439
- linewidth=0.8,
440
- xmin=0,
441
- xmax=1,
442
- clip_on=False,
443
- )
444
-
445
435
  # Calculate size in inches
446
436
  # Until 1.45 we did this on init, but now we'd like to enable dynamic heights
447
437
  if self.requested_height is None:
@@ -112,27 +112,13 @@ class ChoroplethMap(Map):
112
112
 
113
113
  fig = df.plot(ax=self.ax, **args)
114
114
  # Add outer edge
115
- # unary_union does not work with Multipolygons
116
- mp = MultiPolygon([g for g in df.explode(index_parts=True).geometry])
117
- gpd.GeoSeries(mp.boundary).plot(
115
+ gpd.GeoSeries(df.unary_union).plot(
118
116
  ax=self.ax,
119
117
  edgecolor="lightgrey",
120
118
  linewidth=0.2,
119
+ facecolor="none",
121
120
  color="none",
122
121
  )
123
- """
124
- unary = df.unary_union
125
- if unary.geom_type == "Polygon":
126
- # We don't know in advance if unary_union will produce a polugon or a multipolygon
127
- unary = MultiPolygon([unary])
128
- for uu in unary.geoms:
129
- gpd.GeoSeries(uu).plot(
130
- ax=self.ax,
131
- edgecolor="lightgrey",
132
- linewidth=0.2,
133
- facecolor="none",
134
- )
135
- """
136
122
  self.ax.axis("off")
137
123
 
138
124
  # Format numbers in legend
@@ -216,6 +216,7 @@ class SerialChart(Chart):
216
216
  if self.type[i] == "line":
217
217
  # Put first series on top
218
218
  zo = len(series) - i + 1
219
+ zo += 10 # Make sure lines are on top of bars
219
220
 
220
221
  if self.line_width is None:
221
222
  lw = self._nwc_style.get("lines.linewidth", 2)
@@ -243,7 +244,7 @@ class SerialChart(Chart):
243
244
  self.ax.plot(dates[0], values[0],
244
245
  c=color,
245
246
  marker='.',
246
- zorder=2)
247
+ zorder=12)
247
248
  elif num_values > 1:
248
249
  for j, v in enumerate(values):
249
250
  def nullish(val):
@@ -260,7 +261,7 @@ class SerialChart(Chart):
260
261
  self.ax.plot(dates[j], v,
261
262
  c=color,
262
263
  marker='.',
263
- zorder=2)
264
+ zorder=12)
264
265
 
265
266
  if len(self.labels) > i:
266
267
  line.set_label(self.labels[i])
@@ -449,7 +450,7 @@ class SerialChart(Chart):
449
450
  y=self.baseline,
450
451
  linewidth=1,
451
452
  color="#444444",
452
- zorder=4,
453
+ zorder=6,
453
454
  linestyle="--" if self.baseline else "-"
454
455
  )
455
456
  if self.baseline_annotation:
@@ -530,11 +531,11 @@ class SerialChart(Chart):
530
531
  if len(self.labels) > 1:
531
532
  if self.label_placement == "legend":
532
533
  _ = self.ax.legend(loc="best")
533
- _.set(zorder=10)
534
+ _.set(zorder=20)
534
535
  elif self.label_placement == "outside":
535
536
  self.ax.legend(bbox_to_anchor=(0, 1, 1, 0), loc="lower right")
536
537
  elif self.label_placement == "inline":
537
- labelLines(self.ax.get_lines(), align=False, zorder=3, outline_width=4, fontweight="bold")
538
+ labelLines(self.ax.get_lines(), align=False, zorder=13, outline_width=4, fontweight="bold")
538
539
 
539
540
  # Trend/change line
540
541
  if self.trendline:
@@ -551,6 +552,10 @@ class SerialChart(Chart):
551
552
  # Use neutral color for trendline
552
553
  trendline_color = self._nwc_style["neutral_color"]
553
554
 
555
+ if len(self.data) == 1 and self.type[0] == "line":
556
+ # If we have a single line,
557
+ # avoid using the same color for trendline
558
+ trendline_color = self._nwc_style["neutral_color"]
554
559
  # Check if we have a list of single (x-) values, or data points
555
560
  if all(len(x) == 2 for x in self.trendline):
556
561
  # data points
@@ -565,7 +570,7 @@ class SerialChart(Chart):
565
570
  marker = 'o'
566
571
 
567
572
  self.ax.plot(dates, values,
568
- color=trendline_color, zorder=4,
573
+ color=trendline_color, zorder=14,
569
574
  linewidth=1,
570
575
  marker=marker, linestyle='dashed')
571
576
 
@@ -589,6 +594,18 @@ class SerialChart(Chart):
589
594
  if len(value_label_elems) > 1:
590
595
  self._adust_texts_vertically(value_label_elems, ha="center")
591
596
 
597
+ # yline
598
+ if (self.yline):
599
+ self.ax.axhline(
600
+ y=self.yline,
601
+ color=self._nwc_style["neutral_color"],
602
+ linewidth=0.8,
603
+ xmin=0,
604
+ xmax=1,
605
+ clip_on=False,
606
+ zorder=6,
607
+ )
608
+
592
609
  def _adust_texts_vertically(self, elements, ha="left"):
593
610
  if len(elements) == 2:
594
611
  # Hack: check for overlap and adjust labels only
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: newsworthycharts
3
- Version: 1.56.0
3
+ Version: 1.57.1
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.56.0.tar.gz
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.57.1.tar.gz
7
7
  Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
8
8
  Author-email: stockholm@jplusplus.org
9
9
  License: MIT
@@ -11,7 +11,7 @@ Requires-Python: >=3.9
11
11
  Description-Content-Type: text/x-rst
12
12
  License-File: LICENSE.txt
13
13
  Requires-Dist: Babel <3,>=2.14.0
14
- Requires-Dist: Pillow ==10.2.0
14
+ Requires-Dist: Pillow ==10.3.0
15
15
  Requires-Dist: PyYAML >=3
16
16
  Requires-Dist: adjustText ==0.7.3
17
17
  Requires-Dist: boto3 >=1.26
@@ -19,7 +19,7 @@ Requires-Dist: geopandas ==0.14.3
19
19
  Requires-Dist: langcodes >=3.3
20
20
  Requires-Dist: mapclassify ==2.6.1
21
21
  Requires-Dist: matplotlib-label-lines ==0.5.1
22
- Requires-Dist: matplotlib ==3.8.3
22
+ Requires-Dist: matplotlib ==3.8.4
23
23
  Requires-Dist: numpy <2,>=1.21.0
24
24
  Requires-Dist: python-dateutil <3,>=2
25
25
  Requires-Dist: requests >=2.22
@@ -128,9 +128,12 @@ Options
128
128
 
129
129
  **Chart**
130
130
 
131
+ These settings are available for all chart types:
132
+
131
133
  - data: A list of datasets
132
134
  - annotate_trend = True # Print out values at points on trendline?
133
135
  - trendline = [] # List of x positions, or data points
136
+ - yline = None # A horizontal line across the chart (Matplotlib: axhline)
134
137
  - labels = [] # Optionally one label for each dataset
135
138
  - annotations = [] # Manually added annotations
136
139
  - interval = None # yearly|quarterly|monthly|weekly|daily
@@ -146,6 +149,59 @@ Options
146
149
  - logo = None # Path to image that will be embedded in the caption area. Can also be set though a style property
147
150
  - color_fn = None # Custom coloring function
148
151
 
152
+ **SerialChart**
153
+
154
+ - type = 'line' # line|bar|stacked_bar
155
+ - bar_width = 0.9 # percent of data point width
156
+ - allow_broken_y_axis = True|False # default depends on chart type
157
+ - baseline = 0 # The “zero” line. Useful for plotting deviations, e.g. temperatures above/below mean
158
+ - baseline_annotation = None # A label for the baseline
159
+ - line_width = None # To override style settings
160
+ - max_ticks = 7 # Maximum number of ticks on the x axis
161
+ - ticks = None # Custom ticks on the x axis, as a list of lists or tuples: `[(2013-01-01, "-13"), (2014-01-01, "-14"), (2015-01-01, "-15")]`
162
+ - ymin = None # Minimum value on y axis. If None, it will be calculated from data
163
+ - ymax = None # Maximum value on y axis. If None, it will be calculated from data
164
+ - colors = None # A list of colors, each correspoding to one dataseries. Default behaviour is to use the style colors
165
+ - value_labels = False # Print out values at points on line?
166
+ - highlighted_x_ranges = [] # List of tuples with start and end of highlighted areas
167
+ - label_placement = "legend" # legend|inline|outside
168
+ - color_labels = None # A dictionary of label/color, to override style colors
169
+
170
+ **SeasonalChart**
171
+
172
+ **BubbleMap**
173
+
174
+ - bubble_size = 1 # The size of the bubbles
175
+
176
+ **CategoricalChart**
177
+
178
+ - bar_orientation = "horizontal" # [horizontal|vertical]
179
+ - annotation_rotation = 0
180
+ - stacked = False
181
+ - legend = True
182
+ - colors = None
183
+
184
+ **CategoricalChartWithReference**
185
+
186
+ **Map**
187
+
188
+ - bins = 9 # Number of bins for continuous data
189
+ - binning_method = "natural_breaks"
190
+ - colors = None
191
+ - color_ramp = "YlOrRd"
192
+ - categorical = False # If True, the map will be colored by category. If False, it will be colored by a continuous value
193
+ - base_map = None
194
+ - missing_label = None # Add a label for no data
195
+
196
+ **ChoroplethMap**
197
+
198
+ **ProgressChart**
199
+
200
+ **RangePlot**
201
+
202
+ **ScatterPlot**
203
+
204
+ **StripeChart**
149
205
 
150
206
  Developing
151
207
  ----------
@@ -181,6 +237,17 @@ Roadmap
181
237
  Changelog
182
238
  ---------
183
239
 
240
+ - 1.57.1
241
+
242
+ - Fix missing outline in choropleth maps
243
+ - matplotlib==3.8.4; Pillow==10.3.0
244
+
245
+ - 1.57.0
246
+
247
+ - Changed z-ordering so that line are always on top of bars, and ylines/zero lines are behind lines but in front of bars
248
+ - Avoid using the same color for trendline and lines
249
+ - `yline` was moved to the SerialChart class, where it makes sense.
250
+
184
251
  - 1.56.0
185
252
 
186
253
  - Reverted trendline behaviour to 1.54
@@ -1,14 +1,14 @@
1
- newsworthycharts/__init__.py,sha256=Stb7eJUCOxgLmid8Qvz2nSgUPGDl9xWEmElbJQ45PAo,1160
2
- newsworthycharts/bubblemap.py,sha256=_AMj3RkmKDKVmrtj3FuuY776xRUSEf2qE8tG0vQ3Lyg,2619
1
+ newsworthycharts/__init__.py,sha256=KwgSbe7UCJDXJhb66gLqhiZ1or8woAGXKYTXvM3YQo8,1160
2
+ newsworthycharts/bubblemap.py,sha256=nkocWmpiFgfjEuJGAsthjY5X7Q56jXWsZHUGXw4PwgE,2587
3
3
  newsworthycharts/categoricalchart.py,sha256=k2cd96pNysbVU88nZduiLGpzyjMsDXTbASAVu6ov-kI,14686
4
- newsworthycharts/chart.py,sha256=3Xwgtgp1Qf8pq_eR3At40jwQZd2rEvl71Cax3z_3czw,30848
5
- newsworthycharts/choroplethmap.py,sha256=KXtdiRBe-_j_zUozUgdhAWyoYN-eUdFxt9mneN10H1w,6670
4
+ newsworthycharts/chart.py,sha256=YXoK2VvB7t8sfVrCVkLpPulHHsDKQZKAm_aTCig_4ck,30583
5
+ newsworthycharts/choroplethmap.py,sha256=YamK4yf7X5y7VU_13I3iKE4KbwJ1Ie2x9fezwCh17cg,6124
6
6
  newsworthycharts/datawrapper.py,sha256=RRkAVTpfP4updKxUIBaSmKuBi2RUVPaBRF8HDQhlGGA,11250
7
7
  newsworthycharts/map.py,sha256=e0WRcLTmb1KPZ7_-05QXgthMEmKrTpnci40DXnmd6Rc,5984
8
8
  newsworthycharts/rangeplot.py,sha256=NE1W9TnmlpK6T3RvBJOU3nd73EXqkj17OY9i5zlw_cQ,8366
9
9
  newsworthycharts/scatterplot.py,sha256=6iaMoiZx__Gc-2Hcdw-8Ga5dSonrFo3oexKNmSFuir4,4959
10
10
  newsworthycharts/seasonalchart.py,sha256=rr55yqJUkaYDR9Ik98jes6574oY1U8t8LwoLE3gClW4,1967
11
- newsworthycharts/serialchart.py,sha256=nBfXd877V6TsIDZ4QWaONNlft_fL71tkFjnJ1n4tjfs,25081
11
+ newsworthycharts/serialchart.py,sha256=ueDeequZe8Oufi2sBBjf9VyI2-_l767g1wZKqCtY200,25688
12
12
  newsworthycharts/storage.py,sha256=myERhlpvXyExXxUByBq9eW1bWkCyfH9SwTZbsWSyy3Q,4301
13
13
  newsworthycharts/stripechart.py,sha256=9B6PX2MyLuKNQ8W0OGdKbP0-U32kju0K_NHHwwz_J68,1547
14
14
  newsworthycharts/custom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -28,8 +28,8 @@ newsworthycharts/rc/newsworthy,sha256=X0btLNrmk2DRrfOsKj_WCSIgeD6btacEN2tRF_B4m8
28
28
  newsworthycharts/translations/datawrapper_regions.csv,sha256=fzZcQRX6RFMlNNP8mpgfYNdR3Y0QAlQxDXk8FXTaWWI,9214
29
29
  newsworthycharts/translations/regions.py,sha256=Nv1McQjggD4S3JRu82rDMTG3pqUVR13E5-FBpSYbm98,239
30
30
  newsworthycharts/translations/se_municipalities.csv,sha256=br_mm-IvzQtj_W55_ATREhJ97jWnCweBFlDAVY2EBxA,7098
31
- newsworthycharts-1.56.0.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
32
- newsworthycharts-1.56.0.dist-info/METADATA,sha256=SvBL5j5SVZ7R_5R7w8o3rmF_uTB_yC9MFwxfaH2p5A0,24049
33
- newsworthycharts-1.56.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
- newsworthycharts-1.56.0.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
35
- newsworthycharts-1.56.0.dist-info/RECORD,,
31
+ newsworthycharts-1.57.1.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
32
+ newsworthycharts-1.57.1.dist-info/METADATA,sha256=RnpK8VFn5k0_gYUJOEUlLkIAaKb_8Cwm57K9akt8YIg,26362
33
+ newsworthycharts-1.57.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
+ newsworthycharts-1.57.1.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
35
+ newsworthycharts-1.57.1.dist-info/RECORD,,