newsworthycharts 1.58.0__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.
- newsworthycharts/__init__.py +1 -1
- newsworthycharts/chart.py +18 -9
- newsworthycharts/serialchart.py +27 -26
- {newsworthycharts-1.58.0.dist-info → newsworthycharts-1.59.0.dist-info}/METADATA +7 -2
- {newsworthycharts-1.58.0.dist-info → newsworthycharts-1.59.0.dist-info}/RECORD +8 -8
- {newsworthycharts-1.58.0.dist-info → newsworthycharts-1.59.0.dist-info}/LICENSE.txt +0 -0
- {newsworthycharts-1.58.0.dist-info → newsworthycharts-1.59.0.dist-info}/WHEEL +0 -0
- {newsworthycharts-1.58.0.dist-info → newsworthycharts-1.59.0.dist-info}/top_level.txt +0 -0
newsworthycharts/__init__.py
CHANGED
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(
|
263
|
-
|
264
|
-
|
265
|
-
|
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
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
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
|
|
newsworthycharts/serialchart.py
CHANGED
@@ -409,35 +409,36 @@ class SerialChart(Chart):
|
|
409
409
|
self.ax.legend(handles=patches)
|
410
410
|
|
411
411
|
# Annotate highlighted points/bars
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
if
|
417
|
-
|
418
|
-
else:
|
419
|
-
dir = "down"
|
420
|
-
if self.type[i] == "line":
|
421
|
-
if len(highlight_values) > 1:
|
422
|
-
# When highlighting two values on the same point,
|
423
|
-
# put them in opposite direction
|
424
|
-
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:
|
425
418
|
dir = "up"
|
426
|
-
elif hv == min(highlight_values):
|
427
|
-
dir = "down"
|
428
419
|
else:
|
429
|
-
dir = "
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
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
|
435
431
|
else:
|
436
|
-
#
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
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)
|
441
442
|
|
442
443
|
# Add background highlights
|
443
444
|
for (x0, x1) in self.highlighted_x_ranges:
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: newsworthycharts
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.59.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.
|
6
|
+
Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.59.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
|
@@ -145,6 +145,7 @@ These settings are available for all chart types:
|
|
145
145
|
- ylabel = None
|
146
146
|
- caption = None
|
147
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?
|
148
149
|
- decimals = None # None means automatically chose the best number
|
149
150
|
- logo = None # Path to image that will be embedded in the caption area. Can also be set though a style property
|
150
151
|
- color_fn = None # Custom coloring function
|
@@ -242,6 +243,10 @@ Roadmap
|
|
242
243
|
Changelog
|
243
244
|
---------
|
244
245
|
|
246
|
+
- 1.59.0
|
247
|
+
|
248
|
+
- Added `.highlight_annotation` to enable turning off the textual annotation on the highlighted point
|
249
|
+
|
245
250
|
- 1.58.0
|
246
251
|
|
247
252
|
- Matplotlib==3.9
|
@@ -1,14 +1,14 @@
|
|
1
|
-
newsworthycharts/__init__.py,sha256=
|
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=
|
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=
|
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.
|
32
|
-
newsworthycharts-1.
|
33
|
-
newsworthycharts-1.
|
34
|
-
newsworthycharts-1.
|
35
|
-
newsworthycharts-1.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|