newsworthycharts 1.71.4__tar.gz → 1.71.5__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.
- {newsworthycharts-1.71.4/newsworthycharts.egg-info → newsworthycharts-1.71.5}/PKG-INFO +9 -2
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/README.rst +7 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/__init__.py +1 -1
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/rankchart.py +80 -21
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/serialchart.py +3 -1
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5/newsworthycharts.egg-info}/PKG-INFO +9 -2
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/LICENSE.txt +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/MANIFEST.in +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/bubblemap.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/categoricalchart.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/chart.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/choroplethmap.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/custom/__init__.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/custom/climate_cars.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/datawrapper.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/__init__.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/color_fn.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/colors.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/datalist.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/formatter.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/geography.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/locator.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/mimetypes.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/lib/utils.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/map.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/maps/se-4.gpkg +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/maps/se-7.gpkg +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/rangeplot.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/rc/newsworthy +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/scatterplot.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/seasonalchart.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/storage.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/stripechart.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/translations/datawrapper_regions.csv +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/translations/regions.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/translations/se_municipalities.csv +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts.egg-info/SOURCES.txt +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts.egg-info/dependency_links.txt +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts.egg-info/not-zip-safe +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts.egg-info/requires.txt +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts.egg-info/top_level.txt +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/setup.cfg +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/setup.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_categorical_chart.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_choropleth_maps.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_custom_climate_cars.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_data_list.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_datawrapper.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_main.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_rangeplot.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_scatterplot.py +0 -0
- {newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/test/test_serial_chart.py +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: newsworthycharts
|
3
|
-
Version: 1.71.
|
3
|
+
Version: 1.71.5
|
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.71.
|
6
|
+
Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.71.5.tar.gz
|
7
7
|
Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
|
8
8
|
Author-email: stockholm@jplusplus.org
|
9
9
|
License: MIT
|
@@ -179,6 +179,7 @@ _ Inherits from SerialChart _
|
|
179
179
|
|
180
180
|
_ Inherits from SerialChart _
|
181
181
|
|
182
|
+
- label_placement = "right" # [left|right|both|outside|legend]
|
182
183
|
- highlight = None # The label value to of a line to highlight
|
183
184
|
- line_marker = "o-" # Matplotlib line marker type.
|
184
185
|
- line_marker_size = 5 # Matplotlib line marker size
|
@@ -270,6 +271,12 @@ Roadmap
|
|
270
271
|
Changelog
|
271
272
|
---------
|
272
273
|
|
274
|
+
- 1.71.5
|
275
|
+
|
276
|
+
- zorder fixes in BumpChart
|
277
|
+
- Add `label_placement` = [left|right|both|outside|legend] to BumpChart. Default is 'right'
|
278
|
+
- Use alternating shades of gray in BumpChart
|
279
|
+
|
273
280
|
- 1.71.4
|
274
281
|
|
275
282
|
- BumpChart: Use dual colors in line markers when rank is shared
|
@@ -153,6 +153,7 @@ _ Inherits from SerialChart _
|
|
153
153
|
|
154
154
|
_ Inherits from SerialChart _
|
155
155
|
|
156
|
+
- label_placement = "right" # [left|right|both|outside|legend]
|
156
157
|
- highlight = None # The label value to of a line to highlight
|
157
158
|
- line_marker = "o-" # Matplotlib line marker type.
|
158
159
|
- line_marker_size = 5 # Matplotlib line marker size
|
@@ -244,6 +245,12 @@ Roadmap
|
|
244
245
|
Changelog
|
245
246
|
---------
|
246
247
|
|
248
|
+
- 1.71.5
|
249
|
+
|
250
|
+
- zorder fixes in BumpChart
|
251
|
+
- Add `label_placement` = [left|right|both|outside|legend] to BumpChart. Default is 'right'
|
252
|
+
- Use alternating shades of gray in BumpChart
|
253
|
+
|
247
254
|
- 1.71.4
|
248
255
|
|
249
256
|
- BumpChart: Use dual colors in line markers when rank is shared
|
@@ -15,13 +15,18 @@ class BumpChart(SerialChart):
|
|
15
15
|
"""
|
16
16
|
|
17
17
|
def __init__(self, *args, **kwargs):
|
18
|
+
label_placement = kwargs.get("label_placement", None)
|
19
|
+
if label_placement not in ["legend", "outside"]:
|
20
|
+
self.label_placement = "none"
|
21
|
+
|
18
22
|
super(BumpChart, self).__init__(*args, **kwargs)
|
19
23
|
|
20
24
|
if self.line_width is None:
|
21
25
|
self.line_width = 0.9
|
22
26
|
if self.line_marker_size is None:
|
23
27
|
self.line_marker_size = 6
|
24
|
-
|
28
|
+
if not label_placement:
|
29
|
+
self.label_placement = 'right'
|
25
30
|
self.type = "line"
|
26
31
|
self.decimals = 0
|
27
32
|
self.revert_value_axis = True
|
@@ -40,7 +45,11 @@ class BumpChart(SerialChart):
|
|
40
45
|
return self._nwc_style["strong_color"]
|
41
46
|
elif self.colors and i < len(self.colors):
|
42
47
|
return self.colors[i]
|
43
|
-
|
48
|
+
# alternate between dark gray and light gray
|
49
|
+
if i % 2 == 0:
|
50
|
+
return "darkgray"
|
51
|
+
else:
|
52
|
+
return "lightgray"
|
44
53
|
|
45
54
|
"""
|
46
55
|
def _get_marker_fill(self, i):
|
@@ -55,7 +64,6 @@ class BumpChart(SerialChart):
|
|
55
64
|
|
56
65
|
# Recolor markers with more than one line passing through
|
57
66
|
# (MPL does not allow access to individual markers, so we'll overwrite them)
|
58
|
-
|
59
67
|
for date in self.data.x_points:
|
60
68
|
value_colors = {}
|
61
69
|
for i, serie in enumerate(self.data):
|
@@ -98,7 +106,10 @@ class BumpChart(SerialChart):
|
|
98
106
|
zorder=100,
|
99
107
|
)
|
100
108
|
# Add labels
|
101
|
-
|
109
|
+
slots_occupied_right = {
|
110
|
+
to_date(k): [] for k in self.data.x_points
|
111
|
+
}
|
112
|
+
slots_occupied_left = {
|
102
113
|
to_date(k): [] for k in self.data.x_points
|
103
114
|
}
|
104
115
|
# distance between rank ticks
|
@@ -114,23 +125,71 @@ class BumpChart(SerialChart):
|
|
114
125
|
(d, values[idx])
|
115
126
|
for (idx, d) in enumerate(dates) if idx == len(dates) - 1 or np.isnan(values[idx + 1])
|
116
127
|
]
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
128
|
+
|
129
|
+
startpoints = []
|
130
|
+
if self.label_placement == "both":
|
131
|
+
startpoints = [
|
132
|
+
(d, values[idx])
|
133
|
+
for (idx, d) in enumerate(dates)
|
134
|
+
if (idx == 0 or np.isnan(values[idx - 1]) # only if 2 consecutive values come after
|
135
|
+
and (idx < len(dates) - 2)
|
136
|
+
and not np.isnan(values[idx + 1])
|
137
|
+
and not np.isnan(values[idx + 2]))
|
138
|
+
]
|
139
|
+
elif self.label_placement == "left":
|
140
|
+
startpoints = [
|
141
|
+
(d, values[idx])
|
142
|
+
for (idx, d) in enumerate(dates)
|
143
|
+
if idx == 0 or np.isnan(values[idx - 1])
|
144
|
+
]
|
145
|
+
|
146
|
+
if self.label_placement in ["left", "both"]:
|
147
|
+
# We need to move y spine to the left to make room for labels
|
148
|
+
# To save time we'll only measure the with of the longest text string
|
149
|
+
# There will be edge cases where shorter strings taker up more space
|
150
|
+
longest_sp_label = max([len(str(x[1])) for x in startpoints])
|
151
|
+
dummy_text = self.ax.text(0, 0, longest_sp_label, fontsize=self._nwc_style["annotation.fontsize"])
|
152
|
+
_bbox = dummy_text.get_window_extent(renderer=self._fig.canvas.get_renderer())
|
153
|
+
self.ax.spines['left'].set_position(('outward', _bbox.width * 1.15 + 15)) # Add a bit extra space
|
154
|
+
dummy_text.remove()
|
155
|
+
|
156
|
+
if self.label_placement in ["right", "both"]:
|
157
|
+
for ep in endpoints:
|
158
|
+
position = ep[1]
|
159
|
+
while position in slots_occupied_right[ep[0]]:
|
160
|
+
position += 1
|
161
|
+
# pos_diff = position - ep[1]
|
162
|
+
slots_occupied_right[ep[0]].append(position)
|
163
|
+
self._annotate_point(
|
164
|
+
self.labels[i],
|
165
|
+
# (ep[0], ep[1]),
|
166
|
+
(ep[0], position),
|
167
|
+
"right",
|
168
|
+
offset=15,
|
169
|
+
color=color,
|
170
|
+
va="center",
|
171
|
+
# xytext=(15, -abs(y1[1] - y2[1]) * pos_diff),
|
172
|
+
# arrowprops=dict(arrowstyle="->", color=color) if pos_diff > 1 else None,
|
173
|
+
zorder=99,
|
174
|
+
)
|
175
|
+
if self.label_placement in ["left", "both"]:
|
176
|
+
for sp in startpoints:
|
177
|
+
position = sp[1]
|
178
|
+
while position in slots_occupied_left[sp[0]]:
|
179
|
+
position += 1
|
180
|
+
# pos_diff = position - sp[1]
|
181
|
+
slots_occupied_left[sp[0]].append(position)
|
182
|
+
self._annotate_point(
|
183
|
+
self.labels[i],
|
184
|
+
(sp[0], position),
|
185
|
+
"left",
|
186
|
+
offset=15,
|
187
|
+
color=color,
|
188
|
+
va="center",
|
189
|
+
zorder=99,
|
190
|
+
)
|
191
|
+
# Add space for labels on the left
|
192
|
+
|
134
193
|
"""
|
135
194
|
labels = []
|
136
195
|
for i, serie in enumerate(self.data):
|
@@ -52,7 +52,9 @@ class SerialChart(Chart):
|
|
52
52
|
self.colors = None
|
53
53
|
|
54
54
|
# Optional: where to place series label
|
55
|
-
|
55
|
+
# Could be set already by subclass
|
56
|
+
if not hasattr(self, "label_placement"):
|
57
|
+
self.label_placement = "legend" # legend|inline|outside|line
|
56
58
|
|
57
59
|
# Optional: annotate each point with a value label
|
58
60
|
self.value_labels = False
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: newsworthycharts
|
3
|
-
Version: 1.71.
|
3
|
+
Version: 1.71.5
|
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.71.
|
6
|
+
Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.71.5.tar.gz
|
7
7
|
Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
|
8
8
|
Author-email: stockholm@jplusplus.org
|
9
9
|
License: MIT
|
@@ -179,6 +179,7 @@ _ Inherits from SerialChart _
|
|
179
179
|
|
180
180
|
_ Inherits from SerialChart _
|
181
181
|
|
182
|
+
- label_placement = "right" # [left|right|both|outside|legend]
|
182
183
|
- highlight = None # The label value to of a line to highlight
|
183
184
|
- line_marker = "o-" # Matplotlib line marker type.
|
184
185
|
- line_marker_size = 5 # Matplotlib line marker size
|
@@ -270,6 +271,12 @@ Roadmap
|
|
270
271
|
Changelog
|
271
272
|
---------
|
272
273
|
|
274
|
+
- 1.71.5
|
275
|
+
|
276
|
+
- zorder fixes in BumpChart
|
277
|
+
- Add `label_placement` = [left|right|both|outside|legend] to BumpChart. Default is 'right'
|
278
|
+
- Use alternating shades of gray in BumpChart
|
279
|
+
|
273
280
|
- 1.71.4
|
274
281
|
|
275
282
|
- BumpChart: Use dual colors in line markers when rank is shared
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts/translations/regions.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{newsworthycharts-1.71.4 → newsworthycharts-1.71.5}/newsworthycharts.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|