newsworthycharts 1.71.3__py3-none-any.whl → 1.71.4__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.71.3"
1
+ __version__ = "1.71.4"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
@@ -19,6 +19,8 @@ class BumpChart(SerialChart):
19
19
 
20
20
  if self.line_width is None:
21
21
  self.line_width = 0.9
22
+ if self.line_marker_size is None:
23
+ self.line_marker_size = 6
22
24
  self.label_placement = 'none'
23
25
  self.type = "line"
24
26
  self.decimals = 0
@@ -29,7 +31,6 @@ class BumpChart(SerialChart):
29
31
  self.accentuate_baseline = False
30
32
 
31
33
  self.line_marker = "o-"
32
- self.line_marker_size = 5
33
34
 
34
35
  def _get_line_colors(self, i, *args):
35
36
  if not self.data:
@@ -41,15 +42,69 @@ class BumpChart(SerialChart):
41
42
  return self.colors[i]
42
43
  return self._nwc_style["neutral_color"]
43
44
 
45
+ """
46
+ def _get_marker_fill(self, i):
47
+ pass
48
+ """
49
+
44
50
  def _after_add_data(self):
45
51
  # Print out every rank
46
52
  if self.data.max_val < 30:
47
53
  _range = list(range(1, int(self.data.max_val) + 1))
48
54
  self.ax.yaxis.set_ticks(_range, _range)
55
+
56
+ # Recolor markers with more than one line passing through
57
+ # (MPL does not allow access to individual markers, so we'll overwrite them)
58
+
59
+ for date in self.data.x_points:
60
+ value_colors = {}
61
+ for i, serie in enumerate(self.data):
62
+ values = np.array(self.serie_values[i], dtype=np.float64)
63
+ dates = [x[0] for x in serie]
64
+ color = self._get_line_colors(i)
65
+ if date not in dates:
66
+ continue
67
+ idx = dates.index(date)
68
+ if np.isnan(values[idx]):
69
+ continue
70
+ val = int(values[idx])
71
+ if val not in value_colors:
72
+ value_colors[val] = []
73
+ value_colors[val].append(color)
74
+ for val, colors in value_colors.items():
75
+ if len(colors) < 2:
76
+ continue
77
+ elif len(colors) == 2:
78
+ self.ax.plot(
79
+ to_date(date),
80
+ val,
81
+ self.line_marker,
82
+ markersize=self.line_marker_size,
83
+ color="None",
84
+ fillstyle="left",
85
+ markeredgewidth=0,
86
+ markerfacecolor=colors[0],
87
+ markerfacecoloralt=colors[1],
88
+ zorder=100,
89
+ )
90
+ else:
91
+ self.ax.plot(
92
+ to_date(date),
93
+ val,
94
+ self.line_marker,
95
+ markersize=self.line_marker_size,
96
+ color=self._nwc_style["neutral_color"],
97
+ markeredgewidth=0,
98
+ zorder=100,
99
+ )
49
100
  # Add labels
50
101
  slots_occupied = {
51
102
  to_date(k): [] for k in self.data.x_points
52
103
  }
104
+ # distance between rank ticks
105
+ # y1 = self.ax.transData.transform((0, 1))
106
+ # y2 = self.ax.transData.transform((0, 2))
107
+ # dist = abs(y1[1] - y2[1])
53
108
  for i, serie in enumerate(self.data):
54
109
  values = np.array(self.serie_values[i], dtype=np.float64)
55
110
  dates = [to_date(x[0]) for x in serie]
@@ -63,15 +118,18 @@ class BumpChart(SerialChart):
63
118
  position = ep[1]
64
119
  while position in slots_occupied[ep[0]]:
65
120
  position += 1
121
+ # pos_diff = position - ep[1]
66
122
  slots_occupied[ep[0]].append(position)
67
123
  self._annotate_point(
68
124
  self.labels[i],
125
+ # (ep[0], ep[1]),
69
126
  (ep[0], position),
70
127
  "right",
71
128
  offset=15,
72
129
  color=color,
73
130
  va="center",
74
- # arrowprops=dict(arrowstyle="->", color=color),
131
+ # xytext=(15, -abs(y1[1] - y2[1]) * pos_diff),
132
+ # arrowprops=dict(arrowstyle="->", color=color) if pos_diff > 1 else None,
75
133
  )
76
134
  """
77
135
  labels = []
@@ -254,6 +254,9 @@ class SerialChart(Chart):
254
254
  color = self._nwc_style["strong_color"]
255
255
  else:
256
256
  color = self._nwc_style["neutral_color"]
257
+ marker_fill = None
258
+ if hasattr(self, "_get_marker_fill"):
259
+ marker_fill = self._get_marker_fill(i)
257
260
 
258
261
  line, = self.ax.plot(
259
262
  dates,
@@ -261,6 +264,8 @@ class SerialChart(Chart):
261
264
  self.line_marker,
262
265
  markersize=self.line_marker_size,
263
266
  color=color,
267
+ markerfacecolor=marker_fill,
268
+ markeredgewidth=0,
264
269
  zorder=zo,
265
270
  lw=lw,
266
271
  )
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: newsworthycharts
3
- Version: 1.71.3
3
+ Version: 1.71.4
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.3.tar.gz
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.71.4.tar.gz
7
7
  Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
8
8
  Author-email: stockholm@jplusplus.org
9
9
  License: MIT
@@ -270,6 +270,10 @@ Roadmap
270
270
  Changelog
271
271
  ---------
272
272
 
273
+ - 1.71.4
274
+
275
+ - BumpChart: Use dual colors in line markers when rank is shared
276
+
273
277
  - 1.71.3
274
278
 
275
279
  - Revert 1.71.2 changes to rendering, to make file sizes predictable again
@@ -1,4 +1,4 @@
1
- newsworthycharts/__init__.py,sha256=_KQ5nZbWoOfbRV3YzJrGxr7xt4UnnweP_qR4OS8t-P8,1221
1
+ newsworthycharts/__init__.py,sha256=td00iXnqMQX2OHulGsMcB67rnHpUa6xr3PsIQOZ9Evk,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=eXgrNCmfE52rFsvTDkMpCZsmL0oSezdkH---LGYsES8,35062
@@ -6,10 +6,10 @@ newsworthycharts/choroplethmap.py,sha256=Si-01213rWqDKINkhmKV6x5iSMumQveJfrlCnqY
6
6
  newsworthycharts/datawrapper.py,sha256=RRkAVTpfP4updKxUIBaSmKuBi2RUVPaBRF8HDQhlGGA,11250
7
7
  newsworthycharts/map.py,sha256=c409jEO4L8Yr780sJRC0RchR44roAlgOUDAkuk1SfRg,6057
8
8
  newsworthycharts/rangeplot.py,sha256=NE1W9TnmlpK6T3RvBJOU3nd73EXqkj17OY9i5zlw_cQ,8366
9
- newsworthycharts/rankchart.py,sha256=b7MJpei08fzDAbVS1Y4qK9KSmcO4UbnRFwhND-8Ms4Y,4211
9
+ newsworthycharts/rankchart.py,sha256=SAUviXMtUBU5QfncyFoTEHZvK1efre-_2QMkN0rridg,6503
10
10
  newsworthycharts/scatterplot.py,sha256=weHubdMsDGaBTXejg2TqBNPTQ1K-QBpZqJiyQ8EOEc4,5084
11
11
  newsworthycharts/seasonalchart.py,sha256=rr55yqJUkaYDR9Ik98jes6574oY1U8t8LwoLE3gClW4,1967
12
- newsworthycharts/serialchart.py,sha256=aZP8QacKdRnHADiJcQ7d0UDLUlLVnlRdjJzSuGFvLFg,29773
12
+ newsworthycharts/serialchart.py,sha256=HLDPYHnAZis3nUU0JUgOPSD406m7GM-mx6ioaGWc5TU,30009
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.71.3.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
- newsworthycharts-1.71.3.dist-info/METADATA,sha256=nXe9_uwI6gFGEBLs9yRC8N_IMORYb-v25Kex_ESlDlM,33287
34
- newsworthycharts-1.71.3.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
35
- newsworthycharts-1.71.3.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
- newsworthycharts-1.71.3.dist-info/RECORD,,
32
+ newsworthycharts-1.71.4.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
+ newsworthycharts-1.71.4.dist-info/METADATA,sha256=HEEbsFv4sFrAyv6nTTuxpOaPGshwLhTedvuLVcmLAtM,33365
34
+ newsworthycharts-1.71.4.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
35
+ newsworthycharts-1.71.4.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
+ newsworthycharts-1.71.4.dist-info/RECORD,,