newsworthycharts 1.73.0__py3-none-any.whl → 1.73.2__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.73.0"
1
+ __version__ = "1.73.2"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
newsworthycharts/chart.py CHANGED
@@ -427,7 +427,7 @@ class Chart(object):
427
427
  self.ax.xaxis.set_major_formatter(DateFormatter('%Y'))
428
428
 
429
429
  else:
430
- loc = get_best_locator(delta, len(dates), self.interval)
430
+ loc = get_best_locator(delta, len(dates), self.interval, max_ticks=self.max_ticks)
431
431
  self.ax.xaxis.set_major_locator(loc)
432
432
  formatter = Formatter(self._language)
433
433
 
@@ -174,6 +174,11 @@ class ChoroplethMap(Map):
174
174
  # We need to add it ourselves
175
175
  label_order = self.label_order or color_map.keys()
176
176
  for label in reversed(label_order):
177
+ if label not in color_map:
178
+ if str(label) in color_map:
179
+ label = str(label)
180
+ else:
181
+ continue
177
182
  color = color_map[label]
178
183
  # A bit of an hack:
179
184
  # Check if this corresponds to one of our predefined
@@ -229,4 +234,4 @@ class ChoroplethMap(Map):
229
234
  handles=patches,
230
235
  **label_kwargs,
231
236
  )
232
- #self.ax.get_figure().savefig("TST.png", bbox_inches="tight")
237
+ # self.ax.get_figure().savefig("TST.png", bbox_inches="tight")
@@ -1,7 +1,9 @@
1
1
  """ Custom locators and related methods
2
2
  """
3
- from matplotlib.dates import (YearLocator, MonthLocator, DayLocator,
4
- WeekdayLocator)
3
+ from matplotlib.dates import (YearLocator, DayLocator, MonthLocator,
4
+ WeekdayLocator, AutoDateLocator)
5
+ import matplotlib.dates as mdates
6
+
5
7
  from datetime import datetime
6
8
  from dateutil.rrule import MO
7
9
 
@@ -36,7 +38,7 @@ def get_year_ticks(start_date, end_date, max_ticks=5):
36
38
  return selected_dates
37
39
 
38
40
 
39
- def get_best_locator(delta, points, interval=None):
41
+ def get_best_locator(delta, points, interval=None, max_ticks=None):
40
42
  """ Get the optimal locator given a time delta and number of points.
41
43
  This methods will be much more conservative than Matplotlib's AutoLocator,
42
44
  trying to keep the x axis as clean as possible, while still including
@@ -61,10 +63,15 @@ def get_best_locator(delta, points, interval=None):
61
63
  else:
62
64
  # Less than a year:
63
65
  if interval in ["monthly", "quarterly"]:
64
- if points > 12:
65
- return MonthLocator()
66
- else:
66
+ if points < max_ticks:
67
67
  return MonthLocator()
68
+ locator = AutoDateLocator(maxticks=max_ticks)
69
+ _month_intervals = [1, 2, 3, 6]
70
+ locator.intervald = {
71
+ mdates.MONTHLY: _month_intervals, # only allow monthly intervals
72
+ }
73
+ return locator
74
+ # return MonthLocator()
68
75
 
69
76
  elif interval == "weekly":
70
77
  # NB The threshold are not tested thoroughly. Consider adjusting.
@@ -82,7 +89,12 @@ def get_best_locator(delta, points, interval=None):
82
89
 
83
90
  elif interval == "daily" or interval is None:
84
91
  if delta.days > 30:
85
- return MonthLocator()
92
+ locator = AutoDateLocator(maxticks=max_ticks)
93
+ _month_intervals = [1, 2, 3, 6]
94
+ locator.intervald = {
95
+ mdates.MONTHLY: _month_intervals, # only allow monthly intervals
96
+ }
97
+ return locator
86
98
  elif delta.days > 21:
87
99
  return DayLocator(interval=10)
88
100
  elif delta.days > 7:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: newsworthycharts
3
- Version: 1.73.0
3
+ Version: 1.73.2
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.73.0.tar.gz
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.73.2.tar.gz
7
7
  Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
8
8
  Author-email: stockholm@jplusplus.org
9
9
  License: MIT
@@ -160,6 +160,8 @@ These settings are available for all chart types:
160
160
  - baseline = 0 # The “zero” line. Useful for plotting deviations, e.g. temperatures above/below mean
161
161
  - baseline_annotation = None # A label for the baseline
162
162
  - line_width = None # To override style settings
163
+ - line_marker = "-"" # Matplotlib line marker type.
164
+ - line_marker_size = 3 # Matplotlib line marker size
163
165
  - max_ticks = 10 # Maximum number of ticks on the x axis. *Only used with yearly|decennial data* (this is yet to be fixed)
164
166
  - 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")]`
165
167
  - ymin = None # Minimum value on y axis. If None, it will be calculated from data
@@ -271,6 +273,15 @@ Roadmap
271
273
  Changelog
272
274
  ---------
273
275
 
276
+ - 1.73.2
277
+
278
+ - Fix month locator bug for very short series
279
+
280
+ - 1.73.1
281
+
282
+ - More leniant label parsing in ChoroplethMap
283
+ - Make max_ticks work in monthly time series charts.
284
+
274
285
  - 1.73.0
275
286
 
276
287
  - Add `type: "markers"` to serial charts. Uses a thin line with a marker at each data point as default.
@@ -1,8 +1,8 @@
1
- newsworthycharts/__init__.py,sha256=YipNMmrmV-BzA_A-apTdyB5as6cLAALqVZdOHDiU-mo,1221
1
+ newsworthycharts/__init__.py,sha256=1o8ucdOR6SaBd8TcxRAOhCRiD_3h1NrjY74gRgJRCO0,1221
2
2
  newsworthycharts/bubblemap.py,sha256=nkocWmpiFgfjEuJGAsthjY5X7Q56jXWsZHUGXw4PwgE,2587
3
3
  newsworthycharts/categoricalchart.py,sha256=Vr-0yFms0hEVCeUa3vLt3FYBqpX4xLQ8YGPc4LGQN_A,18368
4
- newsworthycharts/chart.py,sha256=V7ZyqHG3ER-W1lSmsrV-V-pciij1TFMK4ga2jLfAVJM,35367
5
- newsworthycharts/choroplethmap.py,sha256=PEhBOw9UD0OyeFRjpCFFoxa2ztT5NeGSYOubo2PaNtA,9210
4
+ newsworthycharts/chart.py,sha256=ebPLEIFAlUrE7N7n0aIqkzayKHHguuF0rVkXDK3OpJU,35393
5
+ newsworthycharts/choroplethmap.py,sha256=dMJYmep3Qt3pC09N3-9dSUxUO6EI3QmLktQRJ-D0bdM,9404
6
6
  newsworthycharts/datawrapper.py,sha256=RRkAVTpfP4updKxUIBaSmKuBi2RUVPaBRF8HDQhlGGA,11250
7
7
  newsworthycharts/map.py,sha256=EGh96tU10y7Kgu1e83_VWQSeABdjP6V-0VM6VTHDxu4,6089
8
8
  newsworthycharts/rangeplot.py,sha256=NE1W9TnmlpK6T3RvBJOU3nd73EXqkj17OY9i5zlw_cQ,8366
@@ -20,7 +20,7 @@ newsworthycharts/lib/colors.py,sha256=U04TDkvoMQkcldRFXfnwyLOTwq1SWW2se-Ad-DNcw9
20
20
  newsworthycharts/lib/datalist.py,sha256=-LdGFE0SOvjLnIRZ6eoJoijDaG3SeUPNIDPBjbm5A2U,6433
21
21
  newsworthycharts/lib/formatter.py,sha256=GNH43hE0bC17OgiV8LYH3YUrEhm7OJh9XzfSV4HVtHo,4838
22
22
  newsworthycharts/lib/geography.py,sha256=K0_teFmuPJwXX7Py-amJB_1YY5_gL2kBYhz1LrRCyTg,584
23
- newsworthycharts/lib/locator.py,sha256=rJHdgiA0LASRzdLINhTeU5zOoq1TCMgge4KOBWSagnM,3041
23
+ newsworthycharts/lib/locator.py,sha256=oF4IbIofzDQsrVXM0WpQdLZMByL4B07pYYvuyVNANa0,3600
24
24
  newsworthycharts/lib/mimetypes.py,sha256=bL9HtVWbn2Of39LcBt4u4yelkr4bGZiyebq3OfLnfFY,237
25
25
  newsworthycharts/lib/utils.py,sha256=zk2hfbZluRcwwxa-N9LocP65HKiHmvgkBw9saAq1lgU,7403
26
26
  newsworthycharts/maps/se-4.gpkg,sha256=oWw5j7FPVpI0ig67jNDim8qSn5SG8rcHp0014-uTKZM,290816
@@ -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.73.0.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
- newsworthycharts-1.73.0.dist-info/METADATA,sha256=lG3pEK6YlZ3XNSdoFjIraPugl-KtxXwKIVwEXd5ZF3M,34390
34
- newsworthycharts-1.73.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
35
- newsworthycharts-1.73.0.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
- newsworthycharts-1.73.0.dist-info/RECORD,,
32
+ newsworthycharts-1.73.2.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
+ newsworthycharts-1.73.2.dist-info/METADATA,sha256=1gwuOipenxv4m9FIG1zbWkpiU7oF2pegK3hvAZ1yYng,34671
34
+ newsworthycharts-1.73.2.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
35
+ newsworthycharts-1.73.2.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
+ newsworthycharts-1.73.2.dist-info/RECORD,,