newsworthycharts 1.57.3__py3-none-any.whl → 1.59.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.57.3"
1
+ __version__ = "1.59.0"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
newsworthycharts/chart.py CHANGED
@@ -61,6 +61,7 @@ class Chart(object):
61
61
  self.ylabel = None
62
62
  self.caption = None
63
63
  self.highlight = None
64
+ self.highlight_annotation = True
64
65
  self.decimals = None
65
66
  self.yline = None
66
67
  self.type = None
@@ -259,10 +260,15 @@ class Chart(object):
259
260
  hextent = (0, self._w)
260
261
  self._set_size(hextent[1] - hextent[0])
261
262
  x1 = hextent[0] / self._w
262
- text = self._fig.text(x1, 0.01, caption,
263
- in_layout=True,
264
- color=self._nwc_style["neutral_color"], wrap=True,
265
- fontsize=self._nwc_style["caption.fontsize"])
263
+ text = self._fig.text(
264
+ x1,
265
+ 0.01,
266
+ caption,
267
+ in_layout=True,
268
+ color=self._nwc_style["neutral_color"],
269
+ wrap=True,
270
+ fontsize=self._nwc_style["caption.fontsize"],
271
+ )
266
272
  self._fig.canvas.draw()
267
273
  wrapped_text = text._get_wrapped_text()
268
274
  text.set_text(wrapped_text)
@@ -272,11 +278,14 @@ class Chart(object):
272
278
 
273
279
  def _add_title(self, title_text):
274
280
  """Add a title."""
275
- # y=1 wraps title heavily, hence .9999
276
- text = self._fig.suptitle(title_text, wrap=True, x=0, y=0.999,
277
- horizontalalignment="left",
278
- multialignment="left",
279
- fontproperties=self._title_font)
281
+ text = self._fig.suptitle(
282
+ title_text, wrap=True,
283
+ x=0,
284
+ y=0.985, # default: 0.98
285
+ horizontalalignment="left",
286
+ multialignment="left",
287
+ fontproperties=self._title_font,
288
+ )
280
289
 
281
290
  self._title_elem = text
282
291
 
@@ -53,6 +53,7 @@ class SerialChart(Chart):
53
53
 
54
54
  # Optional: Adds background color to part of charts
55
55
  self.highlighted_x_ranges = []
56
+ self.x_range_labels = []
56
57
 
57
58
  @property
58
59
  def ymin(self):
@@ -408,41 +409,56 @@ class SerialChart(Chart):
408
409
  self.ax.legend(handles=patches)
409
410
 
410
411
  # Annotate highlighted points/bars
411
- for hv in highlight_values:
412
- value_label = a_formatter(hv)
413
- xy = (highlight_date, hv)
414
- if self.type[i] == "bars":
415
- if hv >= self.baseline:
416
- dir = "up"
417
- else:
418
- dir = "down"
419
- if self.type[i] == "line":
420
- if len(highlight_values) > 1:
421
- # When highlighting two values on the same point,
422
- # put them in opposite direction
423
- if hv == max(highlight_values):
412
+ if self.highlight_annotation:
413
+ for hv in highlight_values:
414
+ value_label = a_formatter(hv)
415
+ xy = (highlight_date, hv)
416
+ if self.type[i] == "bars":
417
+ if hv >= self.baseline:
424
418
  dir = "up"
425
- elif hv == min(highlight_values):
426
- dir = "down"
427
419
  else:
428
- dir = "left" # To the right we have diff annotation
429
- else:
430
- # Otherwise, use what works best with the line shape
431
- if highlight_date in dates:
432
- i = dates.index(highlight_date)
433
- dir = self._get_annotation_direction(i, values)
420
+ dir = "down"
421
+ if self.type[i] == "line":
422
+ if len(highlight_values) > 1:
423
+ # When highlighting two values on the same point,
424
+ # put them in opposite direction
425
+ if hv == max(highlight_values):
426
+ dir = "up"
427
+ elif hv == min(highlight_values):
428
+ dir = "down"
429
+ else:
430
+ dir = "left" # To the right we have diff annotation
434
431
  else:
435
- # This highlight is probably out of range for this dataset
436
- # Could happen if we have two or more lines,
437
- # with different start and end points.
438
- continue
439
- self._annotate_point(value_label, xy, direction=dir)
432
+ # Otherwise, use what works best with the line shape
433
+ if highlight_date in dates:
434
+ i = dates.index(highlight_date)
435
+ dir = self._get_annotation_direction(i, values)
436
+ else:
437
+ # This highlight is probably out of range for this dataset
438
+ # Could happen if we have two or more lines,
439
+ # with different start and end points.
440
+ continue
441
+ self._annotate_point(value_label, xy, direction=dir)
440
442
 
441
443
  # Add background highlights
442
444
  for (x0, x1) in self.highlighted_x_ranges:
443
445
  x0 = to_date(x0)
444
446
  x1 = to_date(x1)
445
447
  self.ax.axvspan(x0, x1, alpha=.4, color="lightgrey", lw=0)
448
+ for idx, t in enumerate(self.x_range_labels):
449
+ if idx >= len(self.highlighted_x_ranges):
450
+ continue
451
+ (x0, x1) = self.highlighted_x_ranges[idx]
452
+ x0 = to_date(x0)
453
+ x1 = to_date(x1)
454
+ _y = self.ymax or self.data.max_val + self.baseline
455
+ self.ax.text(
456
+ x0 + (x1 - x0) / 2,
457
+ _y,
458
+ t,
459
+ ha='center',
460
+ color=self._nwc_style["dark_gray_color"],
461
+ )
446
462
 
447
463
  # Accentuate y=0 || y=baseline
448
464
  # if (self.data.min_val < self.baseline) or self.baseline_annotation:
@@ -0,0 +1,1001 @@
1
+ Metadata-Version: 2.1
2
+ Name: newsworthycharts
3
+ Version: 1.59.0
4
+ Summary: Matplotlib wrapper to create charts and publish them on Amazon S3
5
+ Home-page: https://github.com/jplusplus/newsworthycharts
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.59.0.tar.gz
7
+ Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
8
+ Author-email: stockholm@jplusplus.org
9
+ License: MIT
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/x-rst
12
+ License-File: LICENSE.txt
13
+ Requires-Dist: Babel <3,>=2.14.0
14
+ Requires-Dist: Pillow ==10.3.0
15
+ Requires-Dist: PyYAML >=3
16
+ Requires-Dist: adjustText ==0.7.3
17
+ Requires-Dist: boto3 >=1.26
18
+ Requires-Dist: geopandas ==0.14.4
19
+ Requires-Dist: langcodes >=3.3
20
+ Requires-Dist: mapclassify ==2.6.1
21
+ Requires-Dist: matplotlib-label-lines ==0.5.1
22
+ Requires-Dist: matplotlib ==3.9.0
23
+ Requires-Dist: numpy <2,>=1.21.0
24
+ Requires-Dist: python-dateutil <3,>=2
25
+ Requires-Dist: requests >=2.22
26
+
27
+ This module contains methods for producing graphs and publishing them on Amazon S3, or in the location of your choice.
28
+
29
+ It is written and maintained for `Newsworthy <https://www.newsworthy.se/en/>`_, but could possibly come in handy for other people as well.
30
+
31
+ By `Journalism++ Stockholm <http://jplusplus.org/sv>`_.
32
+
33
+ Installing
34
+ ----------
35
+
36
+ .. code-block:: bash
37
+
38
+ pip install newsworthycharts
39
+
40
+
41
+ Using
42
+ -----
43
+
44
+ This module comes with two classes, `Chart` and `Storage` (and it's subclasses).
45
+ When using the Chart class, the generated chart will be saved as a local file:
46
+
47
+ .. code-block:: python3
48
+
49
+ from newsworthycharts import SerialChart as Chart
50
+
51
+
52
+ c = Chart(600, 800)
53
+ c.title = "Number of smiles per second"
54
+ c.xlabel = "Time"
55
+ c.ylabel = "Smiles"
56
+ c.caption = "Source: Ministry of smiles."
57
+ data_serie_1 = [("2008-01-01", 6.1), ("2009-01-01", 5.9), ("2010-01-01", 6.8)]
58
+ c.data.append(data_serie_1)
59
+ c.highlight = "2010-01-01"
60
+ c.render("test", "png")
61
+
62
+ You can use one of the predefine chart classes to make common chart types. Or you can use Newsworthycharts together with Matplotlib. This is useful is you just want to add text elements such as subtitle, notes or apply a predefine theme.
63
+
64
+ Here is how you would make a pie chart:
65
+
66
+ .. code-block:: python3
67
+
68
+ # data
69
+ labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
70
+ sizes = [15, 30, 45, 10]
71
+
72
+ # setup chart
73
+ chart = Chart(width=800, height=600, storage=local_storage)
74
+ chart.title = "My pie chart"
75
+ chart.subtitle = "Look at all those colors"
76
+
77
+ # NB: Render the chart to `chart.ax`
78
+ chart.ax.pie(sizes, labels=labels, autopct='%1.1f%%')
79
+
80
+ # Save the chart
81
+ chart.render("tailored_chart", "png")
82
+
83
+ You can use a _storage_ object to save file to
84
+ a specific location or cloud service:
85
+
86
+ .. code-block:: python3
87
+
88
+ from newsworthycharts import Chart
89
+ from newsworthycharts import S3Storage
90
+
91
+ s3 = S3Storage("my_bucket")
92
+ c = Chart(600, 800, storage=s3)
93
+ c.title = "Number of smiles per second"
94
+ c.subtitle = "This chart tells you something very important."
95
+ c.xlabel = "Time"
96
+ c.ylabel = "Smiles"
97
+ c.note = "There are some missing smiles in data"
98
+ c.caption = "Source: Ministry of smiles."
99
+ c.render("test", "png")
100
+
101
+
102
+ To store a file in a local folder, use the `LocalStorage` class:
103
+
104
+ .. code-block:: python3
105
+
106
+ from newsworthycharts import LocalStorage
107
+
108
+ storage = LocalStorage("/path/to/generated/charts")
109
+
110
+ Charts are styled using built-in or user-defined styles:
111
+
112
+ .. code-block:: python3
113
+
114
+ from newsworthycharts import Chart
115
+
116
+ # This chart has the newsworthy default style
117
+ c = Chart(600, 800, style="newsworthy")
118
+
119
+ # Style can also be the path to a style file (absolute or relative to current working directory)
120
+ c2 = Chart(600, 800, style="path/to/styles/mystyle.mplstyle")
121
+
122
+ To set up you own style, copy the build-in default: <https://github.com/jplusplus/newsworthycharts/blob/master/newsworthycharts/rc/newsworthy>
123
+
124
+ Newsworthycharts will look first among the predefined style files for the requested style, so if you have a custom style file in you working directory you need to give it a unique name not already in use.
125
+
126
+ Options
127
+ -------
128
+
129
+ **Chart**
130
+
131
+ These settings are available for all chart types:
132
+
133
+ - data: A list of datasets
134
+ - annotate_trend = True # Print out values at points on trendline?
135
+ - trendline = [] # List of x positions, or data points
136
+ - yline = None # A horizontal line across the chart (Matplotlib: axhline)
137
+ - labels = [] # Optionally one label for each dataset
138
+ - annotations = [] # Manually added annotations
139
+ - interval = None # yearly|quarterly|monthly|weekly|daily
140
+ - units = 'number' # number|percent|degrees
141
+ - show_ticks = True # toggle category names, dates, etc
142
+ - subtitle = None
143
+ - note = None
144
+ - xlabel = None
145
+ - ylabel = None
146
+ - caption = None
147
+ - highlight = A position (typically a date, category label or index) to highlight. The semantics may differ somewhat between chart types.
148
+ - highlight_annotation = True # Print out values at highlighted point?
149
+ - decimals = None # None means automatically chose the best number
150
+ - logo = None # Path to image that will be embedded in the caption area. Can also be set though a style property
151
+ - color_fn = None # Custom coloring function
152
+
153
+ **SerialChart**
154
+
155
+ - type = 'line' # line|bar|stacked_bar
156
+ - bar_width = 0.9 # percent of data point width
157
+ - allow_broken_y_axis = True|False # default depends on chart type
158
+ - baseline = 0 # The “zero” line. Useful for plotting deviations, e.g. temperatures above/below mean
159
+ - baseline_annotation = None # A label for the baseline
160
+ - line_width = None # To override style settings
161
+ - max_ticks = 7 # Maximum number of ticks on the x axis
162
+ - 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")]`
163
+ - ymin = None # Minimum value on y axis. If None, it will be calculated from data
164
+ - ymax = None # Maximum value on y axis. If None, it will be calculated from data
165
+ - colors = None # A list of colors, each correspoding to one dataseries. Default behaviour is to use the style colors
166
+ - value_labels = False # Print out values at points on line?
167
+ - highlighted_x_ranges = [] # List of tuples with start and end of highlighted areas
168
+ - x_range_labels = [] # List of labels for highlighted areas
169
+ - label_placement = "legend" # legend|inline|outside
170
+ - color_labels = None # A dictionary of label/color, to override style colors
171
+
172
+ **SeasonalChart**
173
+
174
+ **BubbleMap**
175
+
176
+ - bubble_size = 1 # The size of the bubbles
177
+
178
+ **CategoricalChart**
179
+
180
+ - bar_orientation = "horizontal" # [horizontal|vertical]
181
+ - annotation_rotation = 0
182
+ - stacked = False
183
+ - legend = True
184
+ - colors = None
185
+
186
+ **CategoricalChartWithReference**
187
+
188
+ **Map**
189
+
190
+ - bins = 9 # Number of bins for continuous data
191
+ - binning_method = "natural_breaks"
192
+ - colors = None
193
+ - color_ramp = "YlOrRd"
194
+ - categorical = False # If True, the map will be colored by category. If False, it will be colored by a continuous value
195
+ - base_map = None
196
+ - missing_label = None # Add a label for no data
197
+
198
+ `basemap` can be `{ISO}-{level}` or `{ISO}|{subset}-{level}`.
199
+ For example, `se-4` will show Swedish counties, while `se|03-7` will show municipalities (`se-7`) starting with `03`.
200
+
201
+ **ChoroplethMap**
202
+
203
+ _ Inherits from Map _
204
+
205
+ **ProgressChart**
206
+
207
+ **RangePlot**
208
+
209
+ **ScatterPlot**
210
+
211
+ **StripeChart**
212
+
213
+ Developing
214
+ ----------
215
+
216
+ To run tests:
217
+
218
+ .. code-block:: python3
219
+
220
+ python3 -m flake8
221
+ python3 -m pytest
222
+
223
+ Deployment
224
+ ----------
225
+
226
+ To deploy a new version to [PyPi](https://pypi.org/project/newsworthycharts):
227
+
228
+ 1. Update Changelog below.
229
+ 2. Update the version number in newsworthycharts/__init__.py
230
+ 3. Create and push a git tag: `git tag VERSION; git push --tags` (not strictly needed, but nice)
231
+ 4. Build: `python3 setup.py sdist bdist_wheel`
232
+ 5. Check: `python3 -m twine check dist/newsworthycharts-X.Y.X*`
233
+ 6. Upload: `python3 -m twine upload dist/newsworthycharts-X.Y.X*`
234
+
235
+ ...assuming you have Twine installed (`pip3 install twine`) and configured.
236
+
237
+ Roadmap
238
+ -------
239
+ - Adding more base maps
240
+ - Getting rid of custom settings-hack
241
+ - Custom month locator with equal-width month bars
242
+
243
+ Changelog
244
+ ---------
245
+
246
+ - 1.59.0
247
+
248
+ - Added `.highlight_annotation` to enable turning off the textual annotation on the highlighted point
249
+
250
+ - 1.58.0
251
+
252
+ - Matplotlib==3.9
253
+ - Added `.x_range_labels` to SerialChart
254
+ - Some tweaks to title placement to avoid cropping of diactritics
255
+
256
+ - 1.57.3
257
+
258
+ - Make NW region keys work with map subsets (e.g. `SE|03-7`)
259
+ - Don't crash on subsequent calls to basemap parser
260
+
261
+ - 1.57.2
262
+
263
+ - reduce excessive padding in categorical vertical charts
264
+ - improved padding and margin logic for titles/subtitles (taking line spacing into account)
265
+
266
+ - 1.57.1
267
+
268
+ - Fix missing outline in choropleth maps
269
+ - matplotlib==3.8.4; Pillow==10.3.0
270
+
271
+ - 1.57.0
272
+
273
+ - Changed z-ordering so that line are always on top of bars, and ylines/zero lines are behind lines but in front of bars
274
+ - Avoid using the same color for trendline and lines
275
+ - `yline` was moved to the SerialChart class, where it makes sense.
276
+
277
+ - 1.56.0
278
+
279
+ - Reverted trendline behaviour to 1.54
280
+ - Added `yline` to add a horizontal line across the chart (Matplotlib: axhline).
281
+
282
+ - 1.55.0
283
+
284
+ - Always use neutral color for trendline
285
+
286
+ - 1.54.6
287
+
288
+ - Improved logic for trendline coloring
289
+ - Somewhat thinner trendline
290
+
291
+ - 1.54.5
292
+
293
+ - Improved tick placement in daily charts
294
+ - Minor upgrades: matplotlib==3.8.3; Pillow==10.2.0; geopandas==0.14.3
295
+
296
+ - 1.54.4
297
+
298
+ - Use Babel 2.14, and pin version
299
+ - Require numpy>=1.21.0 (now required by Matplotlib)
300
+ - Patch upgrades: matplotlib==3.8.2; geopandas==0.14.1
301
+
302
+ - 1.54.3
303
+
304
+ - Fix duplicated integer values in y axis
305
+
306
+ - 1.54.2
307
+
308
+ - Make sure that legend is always on top of bars in stacked bar charts
309
+ - Support more stacked categories in serial bar charts
310
+
311
+ - 1.52.2+
312
+
313
+ - Backport various 1.54.x fixes
314
+
315
+ - 1.54.1
316
+
317
+ - Patch upgrade Matplotlib to 3.8.1
318
+
319
+ - 1.54.0
320
+
321
+ - Treat 'jpeg' format as 'jpg'
322
+ - Fixed a rendering bug in stacked bar charts with multiple values being 0
323
+ - Pillow upgraded to 10.1
324
+
325
+ - 1.53.0
326
+
327
+ - Fixed bug in value_labels, trying to access a color value that didn't exist
328
+ - Dropped Python 3.8 support (upstream)
329
+ - Uses Matplotlib 3.8
330
+ - Uses Pillow 10
331
+
332
+ - 1.52.1
333
+
334
+ - Fixed date formatting issue in daily charts
335
+
336
+ - 1.52.0
337
+
338
+ - No longer render EPS files by default.
339
+
340
+ - 1.51.2
341
+
342
+ - _Really_ fix dependencies
343
+
344
+ - 1.51.1
345
+
346
+ - Fix error in dependency verison
347
+
348
+ - 1.51.0
349
+
350
+ - Added `BubbleMap`
351
+ - Added `se-4` basemap for Swedish counties
352
+ - Basemaps can now have multiplygons
353
+ - Downgraded adjustText to 0.7.3, as upgrade broke rendering constistency in some places
354
+
355
+ - 1.50.2
356
+
357
+ - Revert `matplotlib-label-lines` to previous version.
358
+
359
+ - 1.50.0
360
+
361
+ - Dropped Python 3.7 support (upstream)
362
+ - Pinned Pillow to exact version in setup.py, for consistent rendering
363
+ - `StripeChart`: First draft
364
+
365
+ - 1.49.1
366
+
367
+ - `ProgressChart`: Better value label placement.
368
+
369
+ - 1.49.0
370
+
371
+ - `ProgressChart`: Enable custom value labels as third argument in data serie.
372
+
373
+ - 1.48.2
374
+
375
+ - Bug fix: Handle translation in inset maps in `ChoroplethMap`.
376
+
377
+ - 1.48.1
378
+
379
+ - Bug fix: Path to translation file in `ChoroplethMap`.
380
+
381
+ - 1.48.0
382
+
383
+ - `ChoroplethMap`: Allow Newsworthy region names.
384
+ - `RangePlot`: Re-add `start_label` that had been (mistakenly?) commented out.
385
+
386
+ - 1.47.2
387
+
388
+ - Bug fix: Fixes legend issue in `ProgressChart`.
389
+
390
+ - 1.47.1
391
+
392
+ - Data point annotation now works for serial charts as well
393
+ - Bug fix: Re-enable `qualitative_colors` as `color` argument in SerialChart (line).
394
+
395
+ - 1.47.0
396
+
397
+ - Support for rendering jpeg files, as `jpg`
398
+ - Minimum required Python version is now 3.7 (jumping from 3.5)
399
+ - Matplotlib@3.7.1
400
+
401
+ - 1.46.3
402
+
403
+ - Fix z-ordering issue on multiple series (n > 2)
404
+
405
+ - 1.46.2
406
+
407
+ - Fix tag mismatch in dist
408
+
409
+ - 1.46.1
410
+
411
+ - Add missing haversine transform for non-projected crs
412
+
413
+ - 1.46.0
414
+
415
+ - `height` can be set to None for automatic ratio, for chart types that support it. Will default to 1:1 for most chart types, but maps will try to provide a reasonable default based on geometry. Some chart types still require explicit height
416
+ - It is now possible to use subsets of basemaps, by specifying a prefix: `se|03-7` means regions starting with `03` in `se-7`
417
+ - Added .missing_label to ChoroplethMap. If None (default), no label will be printed.
418
+ - Always accentuate base_line (/y=0), and make sure that line is on top of any bars to avoid “floating” bars
419
+ - Improved error handling in ChoroplethMap
420
+ - Clean up figure layout logic (this should speed up rendering somewhat)
421
+
422
+ - 1.45.0
423
+
424
+ - Increased default `max_ticks` in SerialChart to 7
425
+ - Matplotlib==3.7.0
426
+ - adjustText==0.8.0
427
+ - ChoroplethMap legend formatting, following language, decimals and units settings, etc
428
+ - Minor tweaks to the layout algorithm. Might affect padding in some charts.
429
+ - ChoroplethMap now does some basic normalizing of region codes
430
+ - Added some data sanity checks, and improved error messages in ChoroplethMap
431
+ - Added tests for ChoroplethMap
432
+
433
+ - 1.44.4
434
+
435
+ - Do not default to broken y axis if chart contains a bar series.
436
+
437
+ - 1.44.3
438
+
439
+ - Fix bug and occasional crash when using baseline with None values
440
+
441
+ - 1.44.2
442
+
443
+ - Fix crash in serialchart coloring chain
444
+
445
+ - 1.44.1
446
+
447
+ - Fix regression in SeasonalChart bar coloring
448
+
449
+ - 1.44.0
450
+
451
+ - Added grey outline to choropleth maps
452
+ - The `type` argument is now a list with one type per data serie. Using a string is still supported for backwards compability. This makes it possible to make mixed type charts.
453
+ - Reworked, simpler and more stable bar coloring algorithm
454
+ - The `type` argument is no longer a getter/setter
455
+ - Reduced edge for bar chartswith many bars
456
+ - Removed unused, undocumented special colors value `"qualitative_colors"`. We have reasonable defaults for all chart types, that can already be overridden. The qualitative colors are used by default for qualitative data.
457
+ - Removed unused, undocumented support for highlighting a series by label, rather than a value. The first series is highlighted by default, and that behaviour can already be overriden by the `.colors` setting
458
+
459
+ - 1.43.4
460
+
461
+ - Add more space for label title on se-7 maps
462
+
463
+ - 1.43.3
464
+
465
+ - Don't try to render map insets with no data
466
+ - Use style colors in categorical choropleth maps
467
+ - Added missing support for coloring categorical maps with `.colors`
468
+ - Make automatic labeling work on categorical maps with `.colors`
469
+ - Somewhat lighter fill for missing values in choropleth maps (lightgray -> gainsboro)
470
+ - Testing experimental label_title support, to be documented in 1.44.0
471
+
472
+ - 1.43.2
473
+
474
+ - Fixed weird ymax in some baseline cases
475
+ - Added bottom padding when baseline was below data-min
476
+
477
+ - 1.43.1
478
+
479
+ - Fixed cut off-bug with negative baseline
480
+ - Fix coloring bug in warm_cold color_fn with baseline
481
+ - Fix regression with quarterly locator
482
+
483
+ - 1.43.0
484
+
485
+ - Default to weekdays on x-axis if data spans 7 days or less
486
+ - Added `.color_labels` to label bar colors set by `.color_fn`
487
+
488
+ - 1.42.0
489
+
490
+ - Added `.baseline` setting for bar charts
491
+ - `warm_cold` coloring algorithm now works relative `.baseline`
492
+ - Added `.baseline_annotation`
493
+ - `.color_fn` can now be a lambda function (or the name of one of the built in functions), e.g. `chart.color_fn = lambda x: "red" if x < 1.4 else "green"`
494
+ - Bar charts will now always have a small white edge
495
+ - Don't break y axis if data is close to 0
496
+ - Offset quarters will be recognosed as quarters now (e.g. Feb, May, Aug, Nov)
497
+ - Fixed bug in .allow_broken_y_axis implementation, causing y-axis to be broken in too many places
498
+ - Various dependency updates
499
+ - Replaced deprecated PIL.Image.ANTIALIAS with PIL.Image.Resampling.LANCZOS for logotype resizing.
500
+ - Get rid of warnings about missing “glyph 10” when prerendering text to calculate text bos sizes
501
+ - Fixed bug where single values surrounded my None's were not printed out in serial-data line charts. This was an earlier regression that was not noticed for many releases.
502
+
503
+ - 1.41.0
504
+
505
+ - New, experimental chart type: Choropleth maps! Supports both categorical and continuous data.
506
+ - Better support for monthly time series spanning years
507
+ - Fixed bug where missing annotation slots could crash CategoricalChart
508
+
509
+ - 1.40.2
510
+
511
+ - Don't crash on deprecation warning
512
+ - Matplotlib upgraded from 3.6.2 to 3.6.3
513
+ - Pin some critical requirement versions
514
+
515
+ - 1.40.1
516
+
517
+ - Fix floating point bug in percent labels
518
+ - Test fixes
519
+
520
+ - 1.40.0
521
+
522
+ - Auto-decide `.decimals` if None
523
+ - Round 0.5 to 1, etc in value axis labels and annotations (the `ROUND_HALF_UP` behaviour)
524
+ - Add `.force_decimals` to print out e.g. ”1.0”. Requires `.decimals` to be explicitly set
525
+ - Serial Chart: Allow disabling ”broken y axis” feature by setting `allow_broken_y_axis=False`
526
+ - Deprecated `units="count"`. Make all numbers equal. Use `units="number"` and `decimals=0` to get the earlier behaviour.
527
+ - Remove overriding of decimal settings by units = count
528
+ - Remove noisy deprecation warning on user settings in rc files
529
+ - Formatters will now use the correct minus signs for the given locale.
530
+
531
+ - 1.39.1
532
+
533
+ - Added missing metadata to svg
534
+ - Added .__version__ attribute to the package
535
+
536
+ - 1.39.0
537
+
538
+ - Added pdf export, now more widely used than eps
539
+ - Author and software metadata now added to pdf and png, including the exakt NWCharts version used to produce an image
540
+
541
+ - 1.38.2
542
+
543
+ - `S3Storage`: Handle text files.
544
+
545
+ - 1.38.1
546
+
547
+ - Prevent logo from ever being > 155px, to restore previous behaviour.
548
+
549
+ - 1.38.0
550
+
551
+ - Made multi series bar seasonal bar charts work for opposite signs, so that we can make +/- charts
552
+
553
+ - 1.37.3
554
+
555
+ - Bug fix: Don't crash with factor argument in DW charts.
556
+
557
+ - 1.37.2
558
+
559
+ - Fixed rendering bug in non-transparent eps exports with transparent logos
560
+
561
+ - 1.37.1
562
+
563
+ - Fixed bug in argument parsing in S3Storage.save()
564
+
565
+ - 1.37.0
566
+
567
+ - Added `storage_options` argument to `render()` and `render_all()`
568
+ - Unified function signatures across storage classes.
569
+
570
+ - 1.36.0
571
+
572
+ - Added options argument to `S3Storage.save()`
573
+
574
+ - 1.35.0
575
+
576
+ - Enable logo scaling. Provided logos can now be any size, and will be scaled down to an appopriate format.
577
+
578
+ - 1.34.0
579
+
580
+ - Adds `factor` argument to `.render()` and `.render_all()`.
581
+ - Adds missing `transparent` argument to `.render_all()`.
582
+ - Matplotlib @ 3.6.2
583
+ - langcodes @ 3.3 to ensure consistent handling of macro languages (`no` is a valid language)
584
+
585
+ - 1.33.0:
586
+
587
+ - Adds `transparent` argument to render method.
588
+
589
+ - 1.32.3
590
+
591
+ - `ScatterPlot`: Mark labeled dots more clearly.
592
+
593
+ - 1.32.2
594
+
595
+ - `SerialChart`: Better error when timepoints are duplicated.
596
+
597
+ - 1.32.1
598
+
599
+ - Bug fixes: Handle negative values when `ymin=0` in SerialChart and remove line stroke from `highlighted_x_ranges`.
600
+
601
+ - 1.32.0
602
+
603
+ - `SerialChart`: New options: `line_width` and `highlighted_x_ranges`.
604
+
605
+ - 1.31.0
606
+
607
+ - Added `label_placement='outside'` option to SerialChart
608
+
609
+ - 1.30.0
610
+
611
+ - Matplotlib updated from 3.3 to 3.6, including among many, many other things:
612
+ - support for .webp
613
+ - a lot of additions and improvements to rcParams
614
+ - new backends
615
+ - Custom NWCharts parameters to the rc style file is being deprecated, and should eventually be phased out
616
+ - Matplotlib and related modules are now pinned to a specific version
617
+ - Added support for generating webp images!
618
+ - Upgraded pytest to support Python 3.10+
619
+ - Fixed date locators to use thecorrect langauge/locale
620
+ - Added padding on top of title, to avoid cropping diactritics
621
+
622
+ - 1.29.0
623
+
624
+ - `CategoricalChart`: Make it possible to hide legend.
625
+
626
+ - 1.28.1
627
+
628
+ - `CategoricalChartWithReference`: Handle multi color bars.
629
+
630
+ - 1.28.0
631
+
632
+ - `Chart` / `SerialChart`: New feature: Mark broken y axis with symbol.
633
+
634
+ - 1.27.1
635
+
636
+ - `SerialChart`: Force y axis range to to given values when `ymax` and `ymin` is defined.
637
+
638
+ - 1.27.0
639
+
640
+ - `SerialChart`: Enable value labeling of each point on line.
641
+
642
+ - 1.26.1
643
+
644
+ - Highlight only current value in SeasonalChart; use different shades of grey for the rest
645
+
646
+ - 1.26.0
647
+
648
+ - Add `SeasonalChart`, a.k.a the Olsson chart
649
+
650
+ - 1.25.3
651
+
652
+ - ProgressChart: Handle missing values
653
+ - `lib.formatter.Formatter`: Handle null values
654
+
655
+ - 1.25.2
656
+
657
+ - ScatterPlot: Enable ymin and xmin in scatterplot.
658
+
659
+ - 1.25.1
660
+
661
+ - Color annoation outline by background color.
662
+
663
+ - 1.25.0
664
+
665
+ - Improved ScatterPlot.
666
+
667
+ - 1.24.1
668
+
669
+ - Bug fix: Inline labeling on charts with missing data.
670
+
671
+ - 1.24.0
672
+
673
+ - CategoricalChartWithReference: Adds highlight option
674
+
675
+ - 1.23.1
676
+
677
+ - Adds missing dependency.
678
+
679
+ - 1.23.0
680
+
681
+ - SerialChart: Introduces inline labeling on lines
682
+
683
+ - 1.22.1
684
+
685
+ - Tweeks on line labeling
686
+
687
+ - 1.22.0
688
+
689
+ - SerialChart: Introduces labeling on lines (rather than just legends)
690
+
691
+ - 1.21.5
692
+
693
+ - Bug fix: Handle charts without ticks to be able to render pie charts again
694
+
695
+ - 1.21.4
696
+
697
+ - Beter height handling in header and footer.
698
+ - Make Noto Sans default font.
699
+
700
+ - 1.21.3
701
+
702
+ - Enable colors property in stacked bar SerialChart.
703
+
704
+ - 1.21.2
705
+
706
+ - Adjusts x margin in RangePlot to fit value labels better.
707
+ - Increases line spacing in subtitle.
708
+
709
+ - 1.21.1
710
+
711
+ - Bug fix: Small change in Datawrapper API.
712
+ - Make ticks option work with SerialChart.init_from
713
+
714
+ - 1.21.0
715
+
716
+ - New feature: Use base `Chart` class to make custom charts.
717
+ - Bug fix: Labels outside canvas in RangePlot
718
+
719
+ - 1.20.2
720
+
721
+ - ClimateCars: Tweeks on 2030 chart.
722
+
723
+ - 1.20.1
724
+
725
+ - Handle np.int as years.
726
+
727
+ - 1.20.0
728
+
729
+ - CategoricalChart: Highlight multiple values with list
730
+ - Bug fix: ylabel placed outside canvas
731
+ - Style: Align caption with note
732
+
733
+ - 1.19.2
734
+
735
+ - RangePlot: Better label margins and bold labels.
736
+
737
+ - 1.19.1
738
+
739
+ - RangePlot: Rename argument values_labels => value_labels.
740
+
741
+
742
+ - 1.19.0
743
+
744
+ - Pick up qualitative colors from style file.
745
+
746
+ - 1.18.1
747
+
748
+ - Fixed coloring on highlighted progress charts.
749
+ - Adds ability to highlight both ends on range plot.
750
+
751
+ - 1.18.0
752
+
753
+ - Added `ticks` option to SerialChart, to set custom x-axis ticks
754
+ - Added color option to CategoricalChart, to work exactly as in SerialChart
755
+ - Fixed bug with highlight in line charts where some line was outside the highlighted date.
756
+
757
+
758
+ - 1.17.0
759
+
760
+ - Enable multiple targets in progress chart.
761
+
762
+ - 1.16.2
763
+
764
+ - Fixes highlight bug in progress chart.
765
+
766
+ - 1.16.1
767
+
768
+ - Small changes in range plot.
769
+
770
+ - 1.16.0
771
+
772
+ - Adds CO2 budget chart
773
+
774
+ - 1.15.2
775
+
776
+ - ClimateCar chart tweeks.
777
+
778
+ - 1.15.1
779
+
780
+ - Bug fix: Adds newsworthycharts.custom to build.
781
+
782
+ - 1.15.0
783
+
784
+ - Introduces progress charts and removes hard coded font sizes.
785
+
786
+ - 1.14.0
787
+
788
+ - Introduces range plots and enables custom coloring in serial charts.
789
+
790
+ - 1.13.3
791
+
792
+ - Fit long ticks on y axis.
793
+
794
+ - 1.13.2
795
+
796
+ - Set annotation fontsize to same as ticks by default.
797
+
798
+ - 1.13.1
799
+
800
+ - Bug fix: Subtitle placement
801
+
802
+ - 1.13.0
803
+
804
+ - Introduces subtitle and note.
805
+ - Updates default styles to align with Newsworthy style guide.
806
+
807
+
808
+ - 1.12.1
809
+
810
+ - Fit footer by logo height. Fixes bug that caused axis overlag when logo was large.
811
+
812
+ - 1.12.0
813
+
814
+ - Introduces stacked categorical bar charts
815
+
816
+ - 1.11.2
817
+
818
+ - Bug fix: Remove failing attemt to store chart in dw format
819
+
820
+
821
+ - 1.11.1
822
+
823
+ - Corrects zorder and centers tick on CategoricalChartWithReference
824
+
825
+ - 1.11.0
826
+
827
+ - Introduces new chart: CategoricalChartWithReference
828
+
829
+ - 1.10.1
830
+
831
+ - Fixes bad X ticks in weekly SerialChart (and charts that don't start in January).
832
+
833
+ - 1.10.0
834
+
835
+ - Add annotation_rotation option to categorical charts
836
+ - Fix a crash in some special cases with serial charts shorter than a year.
837
+ - Fix a bug where diff between series was not highlighted if one value was close to zero.
838
+
839
+ - 1.9.2
840
+
841
+ - Include translations in build.
842
+
843
+ - 1.9.1
844
+
845
+ - Translates region to Datawrapper standard when making maps.
846
+
847
+ - 1.9.0
848
+
849
+ - Allows list of dicts to be passed to DatawrapperChart to be make tables, categorical maps etc.
850
+
851
+ - 1.8.2
852
+
853
+ - Require requests.
854
+
855
+ - 1.8.1
856
+
857
+ - Bug fixes.
858
+
859
+ - 1.8.0
860
+
861
+ - Introduces Datawrapper Chart type.
862
+
863
+ - 1.7.0
864
+
865
+ - Adds ymax argument (to SerialChart)
866
+ - Bug fix: Handle missing values in SerialChart with line.
867
+
868
+ - 1.6.12
869
+
870
+ - Bug fix: Set y max to stacked max in stacked bar chart.
871
+
872
+ - 1.6.11
873
+
874
+ - Introduces stacked bars to SerialChart.
875
+
876
+ - 1.6.10
877
+
878
+ - Fixes bar_orientation bug with `init_from()`
879
+
880
+ - 1.6.9
881
+
882
+ - Fix an ugly bug where type=line would not work with `init_from()`
883
+
884
+ - 1.6.8
885
+
886
+ - Some cosmetic changes: no legend if only one series, color updates, thinner zero line.
887
+
888
+
889
+ - 1.6.7
890
+
891
+ - Make title and units work with `init_from` again
892
+
893
+ - 1.6.6
894
+
895
+ - Add warm/cold color function
896
+
897
+ - 1.6.5
898
+
899
+ - Really, really make `init_from` work, by allowingly allowing allowed attributes
900
+
901
+ - 1.6.4
902
+
903
+ - Fix bug where `init_from` would sometime duplicate data.
904
+ - Make sure `init_from` does not overwrite class methods.
905
+
906
+ - 1.6.3
907
+
908
+ - Protect private properties from being overwritten by `init_from`
909
+ - When `units` is count, `decimal` should default to 0 if not provided. This sometimes didn't work. Now it does.
910
+
911
+ - 1.6.2
912
+
913
+ - Make `init_from` work as expected with a language argument
914
+
915
+ - 1.6.1
916
+
917
+ - Make `init_from` work as expected with multiple data series
918
+
919
+ - 1.6.0
920
+
921
+ - Added a factory method to create charts from a JSON-like Python object, like so: `SerialChart.init_from(config, storage)`
922
+
923
+ - 1.5.1
924
+
925
+ - Fix packaging error in 1.5.0
926
+
927
+ - 1.5.0
928
+
929
+ - Expose available chart engines in `CHART_ENGINES` constant for dynamic loading
930
+ - Add `color_fn` property, for coloring bars based on value
931
+ - Increase line width in default style
932
+ - Upgrading Numpy could potentially affect how infinity is treated in serial charts.
933
+
934
+ - 1.4.1
935
+
936
+ - Revert text adjusting for categorical charts, as it had issues
937
+
938
+ - 1.4.0
939
+
940
+ - Add new ScatterPlot chart class
941
+ - Improved text adjusting in serial charts
942
+ - More secure YAML file parsing
943
+
944
+ - 1.3.3
945
+
946
+ - Make small bar charts with very many bars look better
947
+
948
+ - 1.3.2
949
+
950
+ - Make labels work again, 1.3.1 broke those in some circumstances
951
+
952
+ - 1.3.1
953
+
954
+ - Make inner_max/min_x work with leading / trailing None values
955
+ - Make sure single, orphaned values are visible (as points) in line charts
956
+
957
+ - 1.3.0
958
+
959
+ - Allow (and recommend) using Matplotlib 3. This may affect how some charts are rendered.
960
+ - Removed undocumented and incomplete Latex support from caption.
961
+ - Don't highlight diff outside either series' extreme ends.
962
+
963
+ - 1.2.1
964
+
965
+ - Use strong color if there is nothing to highlight.
966
+
967
+ - 1.2.0
968
+
969
+ - Fix a bug where `decimals` setting was not used in all annotations. Potentially breaking in some implementations.
970
+ - Make the annotation offset 80% of the fontsize (used to be a hardcoded number of pixels)
971
+
972
+ - 1.1.5
973
+
974
+ - Small cosmetic update: Decrease offset of annotation.
975
+
976
+ - 1.1.4
977
+
978
+ - Require Matplotlib < 3, because we are still relying on some features that are deprecated there. Also, internal changes to Matplot lib may cause some charts to look different depending on version.
979
+
980
+ - 1.1.3
981
+
982
+ - Make annotation use default font size, as relative sizing didn't work here anyway
983
+
984
+ - 1.1.2
985
+
986
+ - Move class properties to method properties to make sure multiple Chart instances work as intended/documented. This will make tests run again.
987
+ - None values in bar charts are not annotated (trying to annotate None values used to result in a crash)
988
+ - More tests
989
+
990
+ - 1.1.1
991
+
992
+ - Annotations should now work as expected on series with missing data
993
+
994
+ - 1.1.0
995
+
996
+ - Fix bug where decimal setting wasn't always respected
997
+ - Make no decimals the default if unit is "count"
998
+
999
+ - 1.0.0
1000
+
1001
+ - First version
@@ -1,14 +1,14 @@
1
- newsworthycharts/__init__.py,sha256=PpwFsYOJecyNvthtoUo5_8GuiKOUzpCvdL30xQmHLqQ,1160
1
+ newsworthycharts/__init__.py,sha256=ql3nVttdON3JXhF6EJyawP8Yqp7_5CVACZVg67qQnVk,1160
2
2
  newsworthycharts/bubblemap.py,sha256=nkocWmpiFgfjEuJGAsthjY5X7Q56jXWsZHUGXw4PwgE,2587
3
3
  newsworthycharts/categoricalchart.py,sha256=LwOZ3VbNy9vzvoK0s77AkbfMt4CXVDSAhnsnBInUIrE,14764
4
- newsworthycharts/chart.py,sha256=zVBkbCX4c3JjPhweXPXELkxbYMJDX1jSDVsoTfS1A7k,30634
4
+ newsworthycharts/chart.py,sha256=VXEJe_g_KahyiUXqXnM3vDS7SQoW1Ppktcj13-A2_oc,30631
5
5
  newsworthycharts/choroplethmap.py,sha256=2b61MuYed8ccc7uZkzuSdZDbqVR7C3OP1ftb_khuaLw,6069
6
6
  newsworthycharts/datawrapper.py,sha256=RRkAVTpfP4updKxUIBaSmKuBi2RUVPaBRF8HDQhlGGA,11250
7
7
  newsworthycharts/map.py,sha256=ruhFEFmGg8DwySDPnEbx_4n57DgHL5LlLKQEnoNmuIU,6225
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=ueDeequZe8Oufi2sBBjf9VyI2-_l767g1wZKqCtY200,25688
11
+ newsworthycharts/serialchart.py,sha256=QjXfPepHVUpxeQvXP9S8BnZwUPY2mSc-5RvGIjZvZhU,26386
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.57.3.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
32
- newsworthycharts-1.57.3.dist-info/METADATA,sha256=QyG_NW74zoiyh0PNXGRD_WrYS3GkvCeVoJEAbST2cUQ,930
33
- newsworthycharts-1.57.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
- newsworthycharts-1.57.3.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
35
- newsworthycharts-1.57.3.dist-info/RECORD,,
31
+ newsworthycharts-1.59.0.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
32
+ newsworthycharts-1.59.0.dist-info/METADATA,sha256=sCsOn00COBf8iSzh5TP71gP4-9vl1TnToi10UrMM4g8,27250
33
+ newsworthycharts-1.59.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
+ newsworthycharts-1.59.0.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
35
+ newsworthycharts-1.59.0.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: newsworthycharts
3
- Version: 1.57.3
4
- Summary: Matplotlib wrapper to create charts and publish them on Amazon S3
5
- Home-page: https://github.com/jplusplus/newsworthycharts
6
- Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.57.3.tar.gz
7
- Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
8
- Author-email: stockholm@jplusplus.org
9
- License: MIT
10
- Requires-Python: >=3.9
11
- License-File: LICENSE.txt
12
- Requires-Dist: Babel <3,>=2.14.0
13
- Requires-Dist: Pillow ==10.3.0
14
- Requires-Dist: PyYAML >=3
15
- Requires-Dist: adjustText ==0.7.3
16
- Requires-Dist: boto3 >=1.26
17
- Requires-Dist: geopandas ==0.14.3
18
- Requires-Dist: langcodes >=3.3
19
- Requires-Dist: mapclassify ==2.6.1
20
- Requires-Dist: matplotlib-label-lines ==0.5.1
21
- Requires-Dist: matplotlib ==3.8.4
22
- Requires-Dist: numpy <2,>=1.21.0
23
- Requires-Dist: python-dateutil <3,>=2
24
- Requires-Dist: requests >=2.22
25
-
26
- Matplotlib wrapper to create charts and publish them on Amazon S3