1
1
# being a bit too dynamic
2
2
from math import ceil
3
+ from typing import TYPE_CHECKING , Tuple
3
4
import warnings
4
5
5
6
import matplotlib .table
6
7
import matplotlib .ticker as ticker
7
8
import numpy as np
8
9
10
+ from pandas ._typing import FrameOrSeries
11
+
9
12
from pandas .core .dtypes .common import is_list_like
10
13
from pandas .core .dtypes .generic import ABCDataFrame , ABCIndexClass , ABCSeries
11
14
12
15
from pandas .plotting ._matplotlib import compat
13
16
17
+ if TYPE_CHECKING :
18
+ from matplotlib .table import Table
19
+
14
20
15
21
def format_date_labels (ax , rot ):
16
22
# mini version of autofmt_xdate
@@ -21,7 +27,7 @@ def format_date_labels(ax, rot):
21
27
fig .subplots_adjust (bottom = 0.2 )
22
28
23
29
24
- def table (ax , data , rowLabels = None , colLabels = None , ** kwargs ):
30
+ def table (ax , data : FrameOrSeries , rowLabels = None , colLabels = None , ** kwargs ) -> "Table" :
25
31
if isinstance (data , ABCSeries ):
26
32
data = data .to_frame ()
27
33
elif isinstance (data , ABCDataFrame ):
@@ -43,7 +49,7 @@ def table(ax, data, rowLabels=None, colLabels=None, **kwargs):
43
49
return table
44
50
45
51
46
- def _get_layout (nplots , layout = None , layout_type = "box" ):
52
+ def _get_layout (nplots : int , layout = None , layout_type : str = "box" ) -> Tuple [ int , int ] :
47
53
if layout is not None :
48
54
if not isinstance (layout , (tuple , list )) or len (layout ) != 2 :
49
55
raise ValueError ("Layout must be a tuple of (rows, columns)" )
@@ -92,14 +98,14 @@ def _get_layout(nplots, layout=None, layout_type="box"):
92
98
93
99
94
100
def _subplots (
95
- naxes = None ,
96
- sharex = False ,
97
- sharey = False ,
98
- squeeze = True ,
101
+ naxes : int ,
102
+ sharex : bool = False ,
103
+ sharey : bool = False ,
104
+ squeeze : bool = True ,
99
105
subplot_kw = None ,
100
106
ax = None ,
101
107
layout = None ,
102
- layout_type = "box" ,
108
+ layout_type : str = "box" ,
103
109
** fig_kw ,
104
110
):
105
111
"""
@@ -369,7 +375,7 @@ def _get_all_lines(ax):
369
375
return lines
370
376
371
377
372
- def _get_xlim (lines ):
378
+ def _get_xlim (lines ) -> Tuple [ float , float ] :
373
379
left , right = np .inf , - np .inf
374
380
for l in lines :
375
381
x = l .get_xdata (orig = False )
0 commit comments