maidr 1.4.2__py3-none-any.whl → 1.4.3__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.
maidr/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "1.4.2"
1
+ __version__ = "1.4.3"
2
2
 
3
3
  from .api import close, render, save_html, show, stacked
4
4
  from .core import Maidr
@@ -24,7 +24,6 @@ class GroupedBarPlot(
24
24
  grouped_ax_schema = {
25
25
  MaidrKey.X.value: self.ax.get_xlabel(),
26
26
  MaidrKey.Y.value: self.ax.get_ylabel(),
27
- MaidrKey.FILL.value: self.ax.get_title(),
28
27
  }
29
28
  return self.merge_dict(base_ax_schema, grouped_ax_schema)
30
29
 
@@ -44,6 +43,9 @@ class GroupedBarPlot(
44
43
  return None
45
44
 
46
45
  x_level = self.extract_level(self.ax)
46
+ if x_level is None:
47
+ return None
48
+
47
49
  data = []
48
50
 
49
51
  self._elements.extend(
@@ -87,9 +87,14 @@ class MultiLinePlot(MaidrPlot, LineExtractorMixin):
87
87
  if not all_lines:
88
88
  return None
89
89
 
90
+ # Try to get series names from legend
91
+ legend_labels = []
92
+ if self.ax.legend_ is not None:
93
+ legend_labels = [text.get_text() for text in self.ax.legend_.get_texts()]
94
+
90
95
  all_lines_data = []
91
96
 
92
- for line in all_lines:
97
+ for i, line in enumerate(all_lines):
93
98
  xydata = line.get_xydata()
94
99
  if xydata is None or not xydata.size: # type: ignore
95
100
  continue
@@ -102,11 +107,19 @@ class MultiLinePlot(MaidrPlot, LineExtractorMixin):
102
107
  line.set_gid(unique_gid)
103
108
 
104
109
  label: str = line.get_label() # type: ignore
110
+
111
+ # Try to get the series name from legend labels
112
+ line_type = ""
113
+ if legend_labels and i < len(legend_labels):
114
+ line_type = legend_labels[i]
115
+ elif not label.startswith("_child"):
116
+ line_type = label
117
+
105
118
  line_data = [
106
119
  {
107
120
  MaidrKey.X: float(x),
108
121
  MaidrKey.Y: float(y),
109
- MaidrKey.FILL: (label if not label.startswith("_child") else ""),
122
+ **({MaidrKey.FILL: line_type} if line_type else {}),
110
123
  }
111
124
  for x, y in line.get_xydata() # type: ignore
112
125
  ]
@@ -23,7 +23,6 @@ class MplfinanceLinePlot(MaidrPlot, LineExtractorMixin):
23
23
 
24
24
  def __init__(self, ax: Axes, **kwargs):
25
25
  super().__init__(ax, PlotType.LINE)
26
- self._line_titles = [] # Store line titles separately
27
26
 
28
27
  def _get_selector(self) -> Union[str, List[str]]:
29
28
  """Return selectors for all lines that have data."""
@@ -48,65 +47,6 @@ class MplfinanceLinePlot(MaidrPlot, LineExtractorMixin):
48
47
 
49
48
  return selectors
50
49
 
51
- def _extract_axes_data(self) -> dict:
52
- """
53
- Extract axis labels for the plot.
54
-
55
- Returns
56
- -------
57
- dict
58
- Dictionary containing x and y axis labels with custom y-label for moving averages.
59
- """
60
- x_labels = self.ax.get_xlabel()
61
- if not x_labels:
62
- x_labels = self.extract_shared_xlabel(self.ax)
63
- if not x_labels:
64
- x_labels = "Date"
65
-
66
- # Get the period from the first line for y-axis label
67
- ma_period = self._extract_moving_average_period()
68
- y_label = (
69
- f"{ma_period}-day mav price ($)"
70
- if ma_period
71
- else "Moving Average Price ($)"
72
- )
73
-
74
- return {MaidrKey.X: x_labels, MaidrKey.Y: y_label}
75
-
76
- def _extract_moving_average_periods(self) -> List[str]:
77
- """
78
- Extract all moving average periods from the _maidr_ma_period attributes set by the mplfinance patch.
79
-
80
- Returns
81
- -------
82
- List[str]
83
- List of moving average periods (e.g., ["3", "6", "30"]).
84
- """
85
- all_lines = self.ax.get_lines()
86
- periods = []
87
- for line in all_lines:
88
- # Get the period that was stored by the mplfinance patch
89
- ma_period = getattr(line, "_maidr_ma_period", None)
90
- if ma_period is not None:
91
- periods.append(str(ma_period))
92
-
93
- # Remove duplicates and sort
94
- periods = sorted(list(set(periods)))
95
-
96
- return periods
97
-
98
- def _extract_moving_average_period(self) -> str:
99
- """
100
- Extract the moving average period from the _maidr_ma_period attribute set by the mplfinance patch.
101
-
102
- Returns
103
- -------
104
- str
105
- The moving average period (e.g., "3", "6", "30") or empty string if no period found.
106
- """
107
- periods = self._extract_moving_average_periods()
108
- return periods[0] if periods else ""
109
-
110
50
  def _extract_plot_data(self) -> Union[List[List[dict]], None]:
111
51
  """Extract data from mplfinance moving average lines."""
112
52
  data = self._extract_line_data()
@@ -151,17 +91,6 @@ class MplfinanceLinePlot(MaidrPlot, LineExtractorMixin):
151
91
  line.set_gid(unique_gid)
152
92
 
153
93
  label: str = line.get_label() # type: ignore
154
-
155
- # Get the period for this specific line
156
- ma_period = getattr(line, "_maidr_ma_period", None)
157
-
158
- # Create title for this line
159
- line_title = (
160
- f"{ma_period}-Day Moving Average Line Plot"
161
- if ma_period
162
- else "Moving Average Line Plot"
163
- )
164
-
165
94
  line_data = []
166
95
 
167
96
  # Check if this line has date numbers from mplfinance
@@ -188,22 +117,12 @@ class MplfinanceLinePlot(MaidrPlot, LineExtractorMixin):
188
117
  point_data = {
189
118
  MaidrKey.X: x_value,
190
119
  MaidrKey.Y: float(y),
120
+ MaidrKey.FILL: (label if not label.startswith("_child") else ""),
191
121
  }
192
122
  line_data.append(point_data)
193
123
 
194
124
  if line_data:
195
- # Create line data with title, axes, and points structure
196
- line_with_metadata = {
197
- "title": line_title,
198
- "axes": {
199
- "x": "Date",
200
- "y": f"{ma_period}-day mav price ($)"
201
- if ma_period
202
- else "Moving Average Price ($)",
203
- },
204
- "points": line_data,
205
- }
206
- all_lines_data.append(line_with_metadata)
125
+ all_lines_data.append(line_data)
207
126
 
208
127
  return all_lines_data if all_lines_data else None
209
128
 
@@ -226,38 +145,43 @@ class MplfinanceLinePlot(MaidrPlot, LineExtractorMixin):
226
145
  """
227
146
  return MplfinanceDataExtractor._convert_date_num_to_string(x_value)
228
147
 
229
- def _extract_line_titles(self) -> List[str]:
148
+ def _extract_moving_average_periods(self) -> List[str]:
230
149
  """
231
- Extract titles for all moving average lines.
150
+ Extract all moving average periods from the _maidr_ma_period attributes set by the mplfinance patch.
232
151
 
233
152
  Returns
234
153
  -------
235
154
  List[str]
236
- List of titles for each line.
155
+ List of moving average periods (e.g., ["3", "6", "30"]).
237
156
  """
238
157
  all_lines = self.ax.get_lines()
239
- titles = []
240
-
158
+ periods = []
241
159
  for line in all_lines:
160
+ # Get the period that was stored by the mplfinance patch
242
161
  ma_period = getattr(line, "_maidr_ma_period", None)
243
- title = (
244
- f"{ma_period}-Day Moving Average Line Plot"
245
- if ma_period
246
- else "Moving Average Line Plot"
247
- )
248
- titles.append(title)
162
+ if ma_period is not None:
163
+ periods.append(str(ma_period))
249
164
 
250
- return titles
165
+ # Remove duplicates and sort
166
+ periods = sorted(list(set(periods)))
167
+
168
+ return periods
169
+
170
+ def _extract_moving_average_period(self) -> str:
171
+ """
172
+ Extract the moving average period from the _maidr_ma_period attribute set by the mplfinance patch.
173
+
174
+ Returns
175
+ -------
176
+ str
177
+ The moving average period (e.g., "3", "6", "30") or empty string if no period found.
178
+ """
179
+ periods = self._extract_moving_average_periods()
180
+ return periods[0] if periods else ""
251
181
 
252
182
  def render(self) -> dict:
253
183
  """Initialize the MAIDR schema dictionary with basic plot information."""
254
- # Use the first line's period for the main title
255
- ma_period = self._extract_moving_average_period()
256
- title = (
257
- f"{ma_period}-Day Moving Averages Line Plot"
258
- if ma_period
259
- else "Moving Averages Line Plot"
260
- )
184
+ title = "Moving Average Line Plot"
261
185
 
262
186
  maidr_schema = {
263
187
  MaidrKey.TYPE: self.type,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: maidr
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: Multimodal Access and Interactive Data Representations
5
5
  License: GPL-3.0-or-later
6
6
  Keywords: accessibility,visualization,sonification,braille,tactile,multimodal,data representation,blind,low vision,visual impairments
@@ -1,4 +1,4 @@
1
- maidr/__init__.py,sha256=WXjwKTG-ThyAevvEASjvfUbjdOvs1iXAhaOhvkyrreo,415
1
+ maidr/__init__.py,sha256=ronOPGSAyAgb4akYAYumS7KQ4yoWwCZaihDG9qPs7dI,415
2
2
  maidr/api.py,sha256=F43mXWsxc7tHdlZqbRlEWkc-RjJVo_zgxCn3NiLBY58,1764
3
3
  maidr/core/__init__.py,sha256=WgxLpSEYMc4k3OyEOf1shOxfEq0ASzppEIZYmE91ThQ,25
4
4
  maidr/core/context_manager.py,sha256=6cT7ZGOApSpC-SLD2XZWWU_H08i-nfv-JUlzXOtvWYw,3374
@@ -13,14 +13,14 @@ maidr/core/plot/__init__.py,sha256=xDIpRGM-4DfaSSL3nKcXrjdMecCHJ6en4K4nA_fPefQ,8
13
13
  maidr/core/plot/barplot.py,sha256=1HfoqyDGKIXkYQnCHN83Ye_faKpNQ3R4wjlbjD5jUyk,2092
14
14
  maidr/core/plot/boxplot.py,sha256=i11GdNuz_c-hilmhydu3ah-bzyVdFoBkNvRi5lpMrrY,9946
15
15
  maidr/core/plot/candlestick.py,sha256=2eLdvZJSIgv9fW918uTn7ROsEGui7H3YaVGGFtqkBIw,5269
16
- maidr/core/plot/grouped_barplot.py,sha256=bRcQcvwkF3Q3aZ3PlhbZ6bHI_AfcqdKUMVvlLL94wXM,2078
16
+ maidr/core/plot/grouped_barplot.py,sha256=_zn4XMeEnSiDHtf6t4-z9ErBqg_CijhAS2CCtlHgYIQ,2077
17
17
  maidr/core/plot/heatmap.py,sha256=yMS-31tS2GW4peds9LtZesMxmmTV_YfqYO5M_t5KasQ,2521
18
18
  maidr/core/plot/histogram.py,sha256=QV5W-6ZJQQcZsrM91JJBX-ONktJzH7yg_et5_bBPfQQ,1525
19
- maidr/core/plot/lineplot.py,sha256=C3xz6uWXYM_mbTq_geb5bP0JdvhcQf6cpfTs78Y6fCM,3852
19
+ maidr/core/plot/lineplot.py,sha256=nBnTfmKE62Fr-L7i0v6dQhY9EXgwubQ-5ilajPZD6NQ,4327
20
20
  maidr/core/plot/maidr_plot.py,sha256=DN4TTRNt_SCqGa_mbkHrnpCk-eUQm71HoFRqs3bB6xk,3868
21
21
  maidr/core/plot/maidr_plot_factory.py,sha256=NW2iFScswgXbAC9rAOo4iMkAFsjY43DAvFioGr0yzx4,2732
22
22
  maidr/core/plot/mplfinance_barplot.py,sha256=feQlVMGA987EvgFii3V5vH74xGtBMBZhNlulU97vQL8,5184
23
- maidr/core/plot/mplfinance_lineplot.py,sha256=SVN81tau_IAsj17NZT-UtUEJ8NKBy-WxD1PznZELKHc,9338
23
+ maidr/core/plot/mplfinance_lineplot.py,sha256=tWfMc3sbc-j3lkuyULF_AVGacZ9jRnE6SEm5VkIlfpA,6969
24
24
  maidr/core/plot/regplot.py,sha256=b7u6bGTz1IxKahplNUrfwIr_OGSwMJ2BuLgFAVjL0s0,2744
25
25
  maidr/core/plot/scatterplot.py,sha256=o0i0uS-wXK9ZrENxneoHbh3-u-2goRONp19Yu9QLsaY,1257
26
26
  maidr/exception/__init__.py,sha256=PzaXoYBhyZxMDcJkuxJugDx7jZeseI0El6LpxIwXyG4,46
@@ -51,7 +51,7 @@ maidr/util/regression_line_utils.py,sha256=yFKr-H0whT_su2YVZwNksBLp5EC5s77sr6HUF
51
51
  maidr/util/svg_utils.py,sha256=2gyzBtNKFHs0utrw1iOlxTmznzivOWQMV2aW8zu2c8E,1442
52
52
  maidr/widget/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  maidr/widget/shiny.py,sha256=wrrw2KAIpE_A6CNQGBtNHauR1DjenA_n47qlFXX9_rk,745
54
- maidr-1.4.2.dist-info/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
55
- maidr-1.4.2.dist-info/METADATA,sha256=9Wm3c8aZvsWjAGCGtGmPVUa6_xDCqaobGN_Asl6uS0c,2664
56
- maidr-1.4.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
57
- maidr-1.4.2.dist-info/RECORD,,
54
+ maidr-1.4.3.dist-info/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
55
+ maidr-1.4.3.dist-info/METADATA,sha256=eBYrdXDE43KDRriEnoVqE0X4mNRZ4RQH1S34D0yjuG4,2664
56
+ maidr-1.4.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
57
+ maidr-1.4.3.dist-info/RECORD,,
File without changes
File without changes