|  | 
| 1 | 1 | from datetime import date | 
| 2 | 2 | import enum | 
| 3 | 3 | import re | 
| 4 |  | -from dateutil import parser | 
| 5 | 4 | from typing import Optional, List, Tuple, Literal, Any, Union, Sequence | 
| 6 | 5 | 
 | 
| 7 | 6 | import matplotlib | 
|  | 
| 21 | 20 | from traitlets.traitlets import Unicode, ObjectName | 
| 22 | 21 | 
 | 
| 23 | 22 | 
 | 
|  | 23 | +def _is_grid_line(line: Line2D) -> bool: | 
|  | 24 | +    x_data = line.get_xdata() | 
|  | 25 | +    if len(x_data) != 2: | 
|  | 26 | +        return False | 
|  | 27 | + | 
|  | 28 | +    y_data = line.get_ydata() | 
|  | 29 | +    if len(y_data) != 2: | 
|  | 30 | +        return False | 
|  | 31 | + | 
|  | 32 | +    if x_data[0] == x_data[1] or y_data[0] == y_data[1]: | 
|  | 33 | +        return True | 
|  | 34 | + | 
|  | 35 | +    return False | 
|  | 36 | + | 
|  | 37 | + | 
| 24 | 38 | class GraphType(str, enum.Enum): | 
| 25 | 39 |     LINE = "line" | 
| 26 | 40 |     SCATTER = "scatter" | 
| @@ -187,6 +201,8 @@ def _extract_info(self, ax: Axes) -> None: | 
| 187 | 201 |         super()._extract_info(ax) | 
| 188 | 202 | 
 | 
| 189 | 203 |         for line in ax.get_lines(): | 
|  | 204 | +            if _is_grid_line(line): | 
|  | 205 | +                continue | 
| 190 | 206 |             label = line.get_label() | 
| 191 | 207 |             if label.startswith("_child"): | 
| 192 | 208 |                 number = int(label[6:]) | 
| @@ -377,23 +393,9 @@ def _get_type_of_graph(ax: Axes) -> GraphType: | 
| 377 | 393 |     if all(isinstance(box_or_path, (PathPatch, Line2D)) for box_or_path in objects): | 
| 378 | 394 |         return GraphType.BOX_AND_WHISKER | 
| 379 | 395 | 
 | 
| 380 |  | -    def is_grid_line(line: Line2D) -> bool: | 
| 381 |  | -        x_data = line.get_xdata() | 
| 382 |  | -        if len(x_data) != 2: | 
| 383 |  | -            return False | 
| 384 |  | - | 
| 385 |  | -        y_data = line.get_ydata() | 
| 386 |  | -        if len(y_data) != 2: | 
| 387 |  | -            return False | 
| 388 |  | - | 
| 389 |  | -        if x_data[0] == x_data[1] or y_data[0] == y_data[1]: | 
| 390 |  | -            return True | 
| 391 |  | - | 
| 392 |  | -        return False | 
| 393 |  | - | 
| 394 | 396 |     filtered = [] | 
| 395 | 397 |     for obj in objects: | 
| 396 |  | -        if isinstance(obj, Line2D) and is_grid_line(obj): | 
|  | 398 | +        if isinstance(obj, Line2D) and _is_grid_line(obj): | 
| 397 | 399 |             continue | 
| 398 | 400 |         filtered.append(obj) | 
| 399 | 401 | 
 | 
|  | 
0 commit comments