newsworthycharts 1.71.0__py3-none-any.whl → 1.71.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.71.0"
1
+ __version__ = "1.71.1"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
newsworthycharts/chart.py CHANGED
@@ -207,9 +207,14 @@ class Chart(object):
207
207
  c = color_name
208
208
  return c
209
209
 
210
- def _annotate_point(self, text, xy,
211
- direction, offset=12,
212
- **kwargs):
210
+ def _annotate_point(
211
+ self,
212
+ text,
213
+ xy,
214
+ direction,
215
+ offset=12,
216
+ **kwargs
217
+ ):
213
218
  """Add a label to a given point.
214
219
 
215
220
  :param text: text content of label
@@ -237,11 +242,11 @@ class Chart(object):
237
242
  elif direction == "left":
238
243
  opts["verticalalignment"] = "center"
239
244
  opts["horizontalalignment"] = "right"
240
- opts["xytext"] = (-offset, 0)
245
+ opts["xytext"] = (-offset, -self._nwc_style["annotation.fontsize"] / 0.75)
241
246
  elif direction == "right":
242
247
  opts["verticalalignment"] = "center"
243
248
  opts["horizontalalignment"] = "left"
244
- opts["xytext"] = (offset, 0)
249
+ opts["xytext"] = (offset, -self._nwc_style["annotation.fontsize"] / 0.75)
245
250
  else:
246
251
  msg = f"'{direction}' is an unknown direction for an annotation"
247
252
  raise Exception(msg)
@@ -679,7 +684,7 @@ class Chart(object):
679
684
  self.ax.invert_yaxis()
680
685
  value_axis = self.ax.get_yaxis()
681
686
  value_ticks = self.ax.get_yticks()
682
- value_ticks = [x for x in value_ticks if x <= self.data.max_val]
687
+ value_ticks = [x for x in value_ticks if x <= self.data.max_val and x >= self.ymin]
683
688
  value_axis.set_ticks(value_ticks)
684
689
  # self.ax.set_ylim(self.data.max_val, self.ymin)
685
690
 
@@ -14,7 +14,9 @@ class BumpChart(SerialChart):
14
14
 
15
15
  def __init__(self, *args, **kwargs):
16
16
  super(BumpChart, self).__init__(*args, **kwargs)
17
- self.line_width = 0.5
17
+
18
+ if self.line_width is None:
19
+ self.line_width = 0.9
18
20
  self.label_placement = 'line'
19
21
  self.type = "line"
20
22
  self.decimals = 0
@@ -22,7 +24,10 @@ class BumpChart(SerialChart):
22
24
  self.ymin = 1
23
25
  self.allow_broken_y_axis = False
24
26
  self.grid = False
27
+ self.accentuate_baseline = False
28
+
25
29
  self.line_marker = "o-"
30
+ self.line_marker_size = 5
26
31
 
27
32
  def _get_line_colors(self, i, *args):
28
33
  if not self.data:
@@ -28,6 +28,7 @@ class SerialChart(Chart):
28
28
  # draw bars and cut ay axis from this line
29
29
  self.baseline = kwargs.get("baseline", 0)
30
30
  self.baseline_annotation = kwargs.get("baseline_annotation", None)
31
+ self.accentuate_baseline = True
31
32
 
32
33
  self.color_labels = kwargs.get("color_labels", None)
33
34
 
@@ -37,6 +38,7 @@ class SerialChart(Chart):
37
38
  self.grid = True
38
39
  self.point_marker = "."
39
40
  self.line_marker = "-"
41
+ self.line_marker_size = 3
40
42
 
41
43
  self.max_ticks = 10
42
44
 
@@ -256,7 +258,7 @@ class SerialChart(Chart):
256
258
  dates,
257
259
  values,
258
260
  self.line_marker,
259
- markersize=4,
261
+ markersize=self.line_marker_size,
260
262
  color=color,
261
263
  zorder=zo,
262
264
  lw=lw,
@@ -303,7 +305,7 @@ class SerialChart(Chart):
303
305
  "right",
304
306
  offset=15,
305
307
  color=color,
306
- va="center"
308
+ va="center",
307
309
  )
308
310
  # store labels to check for overlap later
309
311
  line_label_elems.append(lbl)
@@ -503,13 +505,14 @@ class SerialChart(Chart):
503
505
 
504
506
  # Accentuate y=0 || y=baseline
505
507
  # if (self.data.min_val < self.baseline) or self.baseline_annotation:
506
- self.ax.axhline(
507
- y=self.baseline,
508
- linewidth=1,
509
- color="#444444",
510
- zorder=11,
511
- linestyle="--" if self.baseline else "-"
512
- )
508
+ if self.accentuate_baseline:
509
+ self.ax.axhline(
510
+ y=self.baseline,
511
+ linewidth=1,
512
+ color="#444444",
513
+ zorder=11,
514
+ linestyle="--" if self.baseline else "-"
515
+ )
513
516
  if self.baseline_annotation:
514
517
  xy = (to_date(self.data.outer_min_x), self.baseline)
515
518
  # We only allow baseline to be set for single series bar charts
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: newsworthycharts
3
- Version: 1.71.0
3
+ Version: 1.71.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.71.0.tar.gz
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.71.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
@@ -178,7 +178,9 @@ _ Inherits from SerialChart _
178
178
 
179
179
  _ Inherits from SerialChart _
180
180
 
181
- - highlight: The label value to of a line to highlight
181
+ - highlight = None # The label value to of a line to highlight
182
+ - line_marker = "o-" # Matplotlib line marker type.
183
+ - line_marker_size = 5 # Matplotlib line marker size
182
184
 
183
185
  **BubbleMap**
184
186
 
@@ -267,6 +269,12 @@ Roadmap
267
269
  Changelog
268
270
  ---------
269
271
 
272
+ - 1.71.1
273
+
274
+ - Allow setting line marker size and style in `BumpChart`
275
+ - Various fixes in `BumpChart`
276
+ - Take font size into account when positioning annotations
277
+
270
278
  - 1.71.0
271
279
 
272
280
  - Add `BumpChart`
@@ -1,15 +1,15 @@
1
- newsworthycharts/__init__.py,sha256=mNGMLj9gC8MHheLQftfW3gxIMbVmzuTo9CATDA6O_pw,1221
1
+ newsworthycharts/__init__.py,sha256=FHI9lMZXxj8DQAOroGA-Wh60kaCHGKtJYd9O4fWKOb4,1221
2
2
  newsworthycharts/bubblemap.py,sha256=nkocWmpiFgfjEuJGAsthjY5X7Q56jXWsZHUGXw4PwgE,2587
3
3
  newsworthycharts/categoricalchart.py,sha256=YL3pzq8a7U5F0MpeRIAEwCAHw1BRDyKjoaAhf-UyRDo,18179
4
- newsworthycharts/chart.py,sha256=WGrbn4UndhhKq-fbeHMn9vTaEAW3bSHVXrV-8aRqC_8,35692
4
+ newsworthycharts/chart.py,sha256=8Ys9z-BF5mXJiBx-9_k5yEBrBLA66LscwqhfM5YU9uQ,35807
5
5
  newsworthycharts/choroplethmap.py,sha256=Si-01213rWqDKINkhmKV6x5iSMumQveJfrlCnqYcIJM,8173
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=G80MO0oF57dgb1Xe3fAQ2hGxU6VhXp_VLev8suhCQjE,1154
9
+ newsworthycharts/rankchart.py,sha256=Hv5PyUOfDgaxrzr5RApsE9q6wbd203qbCYqqUjcc_hc,1271
10
10
  newsworthycharts/scatterplot.py,sha256=l2w2JkA_4WzxQG9XG1Pn62IlJOdCMm1VemMiZL0rEfU,4959
11
11
  newsworthycharts/seasonalchart.py,sha256=rr55yqJUkaYDR9Ik98jes6574oY1U8t8LwoLE3gClW4,1967
12
- newsworthycharts/serialchart.py,sha256=o8a1X_g1lBReOTEKlFM_KiEMXHZ6ImBWqlBpDaDCMAE,28220
12
+ newsworthycharts/serialchart.py,sha256=zFc5ss3uOC6S61AgsW4Dm3nqeHTaWIxg40LmC1n1yv4,28380
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.0.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
- newsworthycharts-1.71.0.dist-info/METADATA,sha256=Wcl3NZM1kJhK7HiHsongNyXTmVeOj0iDzMIBThn2U1k,32222
34
- newsworthycharts-1.71.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
35
- newsworthycharts-1.71.0.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
- newsworthycharts-1.71.0.dist-info/RECORD,,
32
+ newsworthycharts-1.71.1.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
+ newsworthycharts-1.71.1.dist-info/METADATA,sha256=S3GUG2BAP-Yprx9ANeUNu6uAqH4T_Daem6yPGxCiWAo,32504
34
+ newsworthycharts-1.71.1.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
35
+ newsworthycharts-1.71.1.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
+ newsworthycharts-1.71.1.dist-info/RECORD,,