@@ -1559,7 +1559,7 @@ def _make_plot(self, fig: Figure) -> None:
1559
1559
rendered with a single LineCollection for a large speed-up while keeping
1560
1560
public behaviour identical to the original per-column path.
1561
1561
"""
1562
- # choose once whether to use the LineCollection fast path
1562
+ # decide once whether we can use the LineCollection fast draw
1563
1563
threshold = 200
1564
1564
use_collection = (
1565
1565
not self ._is_ts_plot ()
@@ -1568,9 +1568,10 @@ def _make_plot(self, fig: Figure) -> None:
1568
1568
and len (self .data .columns ) > threshold
1569
1569
)
1570
1570
1571
+ # choose ts-plot helper vs. regular helper
1571
1572
if self ._is_ts_plot ():
1572
1573
data = maybe_convert_index (self ._get_ax (0 ), self .data )
1573
- x = data .index # dummy (ignored by _ts_plot)
1574
+ x = data .index # dummy; _ts_plot ignores it
1574
1575
plotf = self ._ts_plot
1575
1576
it = data .items ()
1576
1577
else :
@@ -1592,19 +1593,22 @@ def _make_plot(self, fig: Figure) -> None:
1592
1593
if self .color is not None :
1593
1594
kwds ["color" ] = self .color
1594
1595
1595
- style , kwds = self ._apply_style_colors ( # type: ignore[arg-type]
1596
- colors , kwds , i , label
1596
+ style , kwds = self ._apply_style_colors (
1597
+ colors ,
1598
+ kwds ,
1599
+ i ,
1600
+ label , # type: ignore[arg-type]
1597
1601
)
1598
1602
kwds .update (self ._get_errorbars (label = label , index = i ))
1599
1603
1600
1604
label_str = self ._mark_right_label (pprint_thing (label ), index = i )
1601
1605
kwds ["label" ] = label_str
1602
1606
1603
1607
if use_collection :
1604
- # collect vertices for the final LineCollection
1608
+ # collect vertices; defer drawing
1605
1609
segments .append (np .column_stack ((x , y )))
1606
1610
1607
- # keep legend parity with a tiny proxy only if legend is on
1611
+ # tiny proxy only if legend is requested
1608
1612
if self .legend :
1609
1613
proxy = mpl .lines .Line2D (
1610
1614
[],
@@ -1614,7 +1618,7 @@ def _make_plot(self, fig: Figure) -> None:
1614
1618
"linewidth" , mpl .rcParams ["lines.linewidth" ]
1615
1619
),
1616
1620
linestyle = kwds .get ("linestyle" , "-" ),
1617
- marker = kwds .get ("marker" , None ),
1621
+ marker = kwds .get ("marker" ),
1618
1622
)
1619
1623
self ._append_legend_handles_labels (proxy , label_str )
1620
1624
else :
@@ -1630,19 +1634,21 @@ def _make_plot(self, fig: Figure) -> None:
1630
1634
)
1631
1635
self ._append_legend_handles_labels (newlines [0 ], label_str )
1632
1636
1633
- # reset x-limits for true time-series plots
1637
+ # reset x-limits for true ts plots
1634
1638
if self ._is_ts_plot ():
1635
1639
lines = get_all_lines (ax )
1636
1640
left , right = get_xlim (lines )
1637
1641
ax .set_xlim (left , right )
1638
1642
1643
+ # single draw call for fast path
1639
1644
if use_collection and segments :
1640
1645
if self .legend :
1641
1646
lc_colors = [
1642
- cast (mpl .lines .Line2D , h ).get_color () for h in self .legend_handles
1647
+ cast (mpl .lines .Line2D , h ).get_color () # mypy: h is Line2D
1648
+ for h in self .legend_handles
1643
1649
]
1644
1650
else :
1645
- # no legend - just follow the default colour cycle
1651
+ # no legend - repeat default colour cycle
1646
1652
base = mpl .rcParams ["axes.prop_cycle" ].by_key ()["color" ]
1647
1653
lc_colors = list (itertools .islice (itertools .cycle (base ), len (segments )))
1648
1654
0 commit comments