newsworthycharts 1.57.0__py3-none-any.whl → 1.57.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.57.0"
1
+ __version__ = "1.57.2"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
@@ -16,7 +16,7 @@ class CategoricalChart(Chart):
16
16
  self.stacked = False
17
17
  self.legend = True
18
18
 
19
- # Optional: specify a list of colors (for mulitple datasets)
19
+ # Optional: specify a list of colors (for multiple datasets)
20
20
  self.colors = None
21
21
 
22
22
  def _add_data(self):
@@ -144,8 +144,8 @@ class CategoricalChart(Chart):
144
144
  kwargs["bottom"] = cum_values[i - 1]
145
145
  self.ax.bar(bar_pos, values, **kwargs)
146
146
 
147
- margin = 0.02 # above and below first/last bar on horizontal
148
147
  if self.bar_orientation == "horizontal":
148
+ margin = 0.02 # above and below first/last bar on horizontal
149
149
  self.ax.set_yticks(bar_pos)
150
150
  self.ax.set_yticklabels(categories)
151
151
  self.ax.invert_yaxis()
@@ -158,6 +158,7 @@ class CategoricalChart(Chart):
158
158
  self._fig.subplots_adjust(left=margin)
159
159
 
160
160
  elif self.bar_orientation == "vertical":
161
+ margin = 0.01 # above and below first/last bar on horizontal
161
162
  self.ax.margins(margin, 0)
162
163
  self.ax.set_xticks(bar_pos)
163
164
  self.ax.set_xticklabels(categories)
newsworthycharts/chart.py CHANGED
@@ -168,7 +168,7 @@ class Chart(object):
168
168
  ismath=False,
169
169
  )
170
170
  num_lines = len(obj._get_wrapped_text().split("\n"))
171
- return (h * num_lines) / float(self._h)
171
+ return (h * (num_lines * 1.4)) / float(self._h) # 1.4 is the line spacing used everywhere
172
172
 
173
173
  def _rel_height(self, obj):
174
174
  """ Get the relative height of a chart object to the whole canvas.
@@ -273,7 +273,7 @@ class Chart(object):
273
273
  def _add_title(self, title_text):
274
274
  """Add a title."""
275
275
  # y=1 wraps title heavily, hence .9999
276
- text = self._fig.suptitle(title_text, wrap=True, x=0, y=0.985,
276
+ text = self._fig.suptitle(title_text, wrap=True, x=0, y=0.999,
277
277
  horizontalalignment="left",
278
278
  multialignment="left",
279
279
  fontproperties=self._title_font)
@@ -755,7 +755,7 @@ class Chart(object):
755
755
  rel_height = 0
756
756
  if self._title_elem:
757
757
  rel_height += self._text_rel_height(self._title_elem)
758
- # Adds a fixes margin below
758
+ # Adds a fixed margin below
759
759
  rel_height += 30 / self._h
760
760
  return rel_height
761
761
 
@@ -764,8 +764,8 @@ class Chart(object):
764
764
  rel_height = 0
765
765
  if self._subtitle_elem:
766
766
  rel_height += self._text_rel_height(self._subtitle_elem)
767
- # Adds a fixes margin below
768
- rel_height += 30 / self._h
767
+ # Adds a fixed margin below
768
+ rel_height += 15 / self._h
769
769
  return rel_height
770
770
 
771
771
  @property
@@ -773,7 +773,7 @@ class Chart(object):
773
773
  rel_height = 0
774
774
  if self._note_elem:
775
775
  rel_height += self._text_rel_height(self._note_elem)
776
- # Adds a fixes margin below
776
+ # Adds a fixed margin below
777
777
  rel_height += 10 / self._h
778
778
  return rel_height
779
779
 
@@ -2,7 +2,6 @@
2
2
  Simple choropleths for common administrative areas
3
3
  """
4
4
  from .map import Map
5
- from shapely.geometry.multipolygon import MultiPolygon
6
5
  import geopandas as gpd
7
6
  import numpy as np
8
7
  import pandas as pd
@@ -112,27 +111,13 @@ class ChoroplethMap(Map):
112
111
 
113
112
  fig = df.plot(ax=self.ax, **args)
114
113
  # Add outer edge
115
- # unary_union does not work with Multipolygons
116
- mp = MultiPolygon([g for g in df.explode(index_parts=True).geometry])
117
- gpd.GeoSeries(mp.boundary).plot(
114
+ gpd.GeoSeries(df.unary_union).plot(
118
115
  ax=self.ax,
119
116
  edgecolor="lightgrey",
120
117
  linewidth=0.2,
118
+ facecolor="none",
121
119
  color="none",
122
120
  )
123
- """
124
- unary = df.unary_union
125
- if unary.geom_type == "Polygon":
126
- # We don't know in advance if unary_union will produce a polugon or a multipolygon
127
- unary = MultiPolygon([unary])
128
- for uu in unary.geoms:
129
- gpd.GeoSeries(uu).plot(
130
- ax=self.ax,
131
- edgecolor="lightgrey",
132
- linewidth=0.2,
133
- facecolor="none",
134
- )
135
- """
136
121
  self.ax.axis("off")
137
122
 
138
123
  # Format numbers in legend
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: newsworthycharts
3
- Version: 1.57.0
3
+ Version: 1.57.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.57.0.tar.gz
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.57.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
@@ -11,7 +11,7 @@ Requires-Python: >=3.9
11
11
  Description-Content-Type: text/x-rst
12
12
  License-File: LICENSE.txt
13
13
  Requires-Dist: Babel <3,>=2.14.0
14
- Requires-Dist: Pillow ==10.2.0
14
+ Requires-Dist: Pillow ==10.3.0
15
15
  Requires-Dist: PyYAML >=3
16
16
  Requires-Dist: adjustText ==0.7.3
17
17
  Requires-Dist: boto3 >=1.26
@@ -19,7 +19,7 @@ Requires-Dist: geopandas ==0.14.3
19
19
  Requires-Dist: langcodes >=3.3
20
20
  Requires-Dist: mapclassify ==2.6.1
21
21
  Requires-Dist: matplotlib-label-lines ==0.5.1
22
- Requires-Dist: matplotlib ==3.8.3
22
+ Requires-Dist: matplotlib ==3.8.4
23
23
  Requires-Dist: numpy <2,>=1.21.0
24
24
  Requires-Dist: python-dateutil <3,>=2
25
25
  Requires-Dist: requests >=2.22
@@ -237,9 +237,19 @@ Roadmap
237
237
  Changelog
238
238
  ---------
239
239
 
240
+ - 1.57.2
241
+
242
+ - reduce excessive padding in ctagoerical vertical charts
243
+ - improved padding and margin logic for titles/subtitles (taking line spacing into account)
244
+
245
+ - 1.57.1
246
+
247
+ - Fix missing outline in choropleth maps
248
+ - matplotlib==3.8.4; Pillow==10.3.0
249
+
240
250
  - 1.57.0
241
251
 
242
- - Changes z-ordering so that line are always on top of bars, and ylines/zero lines are behind lines but in front of bars
252
+ - Changed z-ordering so that line are always on top of bars, and ylines/zero lines are behind lines but in front of bars
243
253
  - Avoid using the same color for trendline and lines
244
254
  - `yline` was moved to the SerialChart class, where it makes sense.
245
255
 
@@ -1,8 +1,8 @@
1
- newsworthycharts/__init__.py,sha256=0EmWb4rjYZY3jGZjmYnlqCVzAZND9rAt_tU_BlZn8bc,1160
1
+ newsworthycharts/__init__.py,sha256=KmKpBttYKLayAfnuYYhLGJXXIEJpN8HluaOsuR1GFIw,1160
2
2
  newsworthycharts/bubblemap.py,sha256=nkocWmpiFgfjEuJGAsthjY5X7Q56jXWsZHUGXw4PwgE,2587
3
- newsworthycharts/categoricalchart.py,sha256=k2cd96pNysbVU88nZduiLGpzyjMsDXTbASAVu6ov-kI,14686
4
- newsworthycharts/chart.py,sha256=YXoK2VvB7t8sfVrCVkLpPulHHsDKQZKAm_aTCig_4ck,30583
5
- newsworthycharts/choroplethmap.py,sha256=KXtdiRBe-_j_zUozUgdhAWyoYN-eUdFxt9mneN10H1w,6670
3
+ newsworthycharts/categoricalchart.py,sha256=LwOZ3VbNy9vzvoK0s77AkbfMt4CXVDSAhnsnBInUIrE,14764
4
+ newsworthycharts/chart.py,sha256=zVBkbCX4c3JjPhweXPXELkxbYMJDX1jSDVsoTfS1A7k,30634
5
+ newsworthycharts/choroplethmap.py,sha256=2b61MuYed8ccc7uZkzuSdZDbqVR7C3OP1ftb_khuaLw,6069
6
6
  newsworthycharts/datawrapper.py,sha256=RRkAVTpfP4updKxUIBaSmKuBi2RUVPaBRF8HDQhlGGA,11250
7
7
  newsworthycharts/map.py,sha256=e0WRcLTmb1KPZ7_-05QXgthMEmKrTpnci40DXnmd6Rc,5984
8
8
  newsworthycharts/rangeplot.py,sha256=NE1W9TnmlpK6T3RvBJOU3nd73EXqkj17OY9i5zlw_cQ,8366
@@ -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.57.0.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
32
- newsworthycharts-1.57.0.dist-info/METADATA,sha256=_Q3joR57Aym1pw9ITzHyYR8xdvSpPVduiqJF_gJlB2I,26270
33
- newsworthycharts-1.57.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
- newsworthycharts-1.57.0.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
35
- newsworthycharts-1.57.0.dist-info/RECORD,,
31
+ newsworthycharts-1.57.2.dist-info/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
32
+ newsworthycharts-1.57.2.dist-info/METADATA,sha256=1OrCBrpa5SOFS01LD7FlqCo3CIIO_ok4rBKmg1TGo3c,26527
33
+ newsworthycharts-1.57.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
+ newsworthycharts-1.57.2.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
35
+ newsworthycharts-1.57.2.dist-info/RECORD,,