@@ -696,7 +696,7 @@ def _plot_redirect(self, name, *args, **kwargs):
696
696
if getattr (self , 'name' , '' ) == 'basemap' :
697
697
return getattr (self .projection , name )(* args , ax = self , ** kwargs )
698
698
else :
699
- return getattr (maxes . Axes , name )(self , * args , ** kwargs )
699
+ return getattr (super () , name )(self , * args , ** kwargs )
700
700
701
701
def _range_gridspec (self , x ):
702
702
"""
@@ -1244,7 +1244,7 @@ def areax(self, *args, **kwargs):
1244
1244
# bar = _bar_wrapper(_standardize_1d(_indicate_error(_cycle_changer(
1245
1245
@plot ._concatenate_docstrings
1246
1246
@docstring .add_snippets
1247
- @plot ._add_autoformat
1247
+ @plot ._with_autoformat
1248
1248
def bar (
1249
1249
self , x = None , height = None , width = 0.8 , bottom = None , * ,
1250
1250
vert = None , orientation = 'vertical' , stacked = False ,
@@ -1268,6 +1268,23 @@ def bar(
1268
1268
kwargs , kwargs_legend_colorbar = plot ._parse_cycle (** kwargs )
1269
1269
kwargs , kwargs_error = plot ._parse_error (** kwargs )
1270
1270
1271
+ # Get step size for bar plots
1272
+ # WARNING: This will fail for non-numeric non-datetime64 singleton
1273
+ # datatypes but this is good enough for vast majority of cases.
1274
+ if not stacked and not getattr (self , '_absolute_bar_width' , False ):
1275
+ x_test = np .atleast_1d (_to_ndarray (x ))
1276
+ if len (x_test ) >= 2 :
1277
+ x_step = x_test [1 :] - x_test [:- 1 ]
1278
+ x_step = np .concatenate ((x_step , x_step [- 1 :]))
1279
+ elif x_test .dtype == np .datetime64 :
1280
+ x_step = np .timedelta64 (1 , 'D' )
1281
+ else :
1282
+ x_step = np .array (0.5 )
1283
+ if np .issubdtype (x_test .dtype , np .datetime64 ):
1284
+ # Avoid integer timedelta truncation
1285
+ x_step = x_step .astype ('timedelta64[ns]' )
1286
+ width = width * x_step / ncols
1287
+
1271
1288
# Parse args
1272
1289
# TODO: Stacked feature is implemented in `cycle_changer`, but makes more
1273
1290
# sense do document here; figure out way to move it here?
@@ -1369,7 +1386,7 @@ def boxes(self, *args, **kwargs):
1369
1386
# boxplot = _boxplot_wrapper(_standardize_1d(_cycle_changer(
1370
1387
@plot ._concatenate_docstrings
1371
1388
@docstring .add_snippets
1372
- @plot ._add_autoformat
1389
+ @plot ._with_autoformat
1373
1390
def boxplot (
1374
1391
self , * args ,
1375
1392
color = 'k' , fill = True , fillcolor = None , fillalpha = 0.7 ,
@@ -1716,10 +1733,19 @@ def contour(self, *args, **kwargs):
1716
1733
%(plot.auto_colorbar)s
1717
1734
%(plot.cmap_args)s
1718
1735
"""
1736
+ # Parse arguments
1719
1737
args = plot ._parse_2d (* args )
1720
1738
kwargs , kwargs_colorbar = plot ._parse_cmap (** kwargs )
1739
+ kwargs , kwargs_label = plot ._parse_labels (** kwargs )
1740
+
1741
+ # Call main function
1721
1742
mappable = self ._plot_redirect ('contour' , * args , ** kwargs )
1743
+
1744
+ # Post-processing
1745
+ plot ._auto_contour_labels (mappable , ** kwargs_label )
1722
1746
plot ._auto_colorbar (mappable , ** kwargs_colorbar )
1747
+ plot ._edgefix_contour (mappable )
1748
+
1723
1749
return mappable
1724
1750
1725
1751
@plot ._concatenate_docstrings
@@ -1840,7 +1866,7 @@ def _fill_between_apply(
1840
1866
1841
1867
@plot ._concatenate_docstrings
1842
1868
@docstring .add_snippets
1843
- @plot ._add_autoformat
1869
+ @plot ._with_autoformat
1844
1870
def fill_between (self , * args , ** kwargs ):
1845
1871
"""
1846
1872
%(axes.fill_between)s
@@ -1849,7 +1875,7 @@ def fill_between(self, *args, **kwargs):
1849
1875
1850
1876
@plot ._concatenate_docstrings
1851
1877
@docstring .add_snippets
1852
- @plot ._add_autoformat
1878
+ @plot ._with_autoformat
1853
1879
def fill_betweenx (self , * args , ** kwargs ):
1854
1880
"""
1855
1881
%(axes.fill_betweenx)s
@@ -1934,7 +1960,7 @@ def hexbin(self, *args, **kwargs):
1934
1960
# hist = _hist_wrapper(_standardize_1d(_cycle_changer(
1935
1961
@plot ._concatenate_docstrings
1936
1962
@docstring .add_snippets
1937
- @plot ._add_autoformat
1963
+ @plot ._with_autoformat
1938
1964
def hist (self , x , bins = None , ** kwargs ):
1939
1965
"""
1940
1966
Add histogram(s).
@@ -2395,7 +2421,7 @@ def parametric(
2395
2421
)
2396
2422
else :
2397
2423
raise ValueError ('Missing required keyword argument "values".' )
2398
- cmap , norm , kwargs = plot ._parse_cmap_norm (** kwargs )
2424
+ kwargs , kwargs_colorbar = plot ._parse_cmap (** kwargs )
2399
2425
2400
2426
# Verify shapes
2401
2427
x , y , values = np .atleast_1d (x ), np .atleast_1d (y ), np .atleast_1d (values )
@@ -2446,27 +2472,26 @@ def parametric(
2446
2472
coords .append (np .concatenate ((pleft , pright ), axis = 0 ))
2447
2473
coords = np .array (coords )
2448
2474
2449
- # Create LineCollection and update with values
2475
+ # Add LineCollection and update with values
2450
2476
# NOTE: Default capstyle is butt but this may look weird with vector graphics
2451
- obj = mcollections .LineCollection (
2452
- coords , cmap = cmap , norm = norm ,
2453
- linestyles = '-' , capstyle = 'butt' , joinstyle = 'miter' ,
2454
- )
2455
- values = np .asarray (values )
2456
- obj .set_array (values )
2457
- obj .update ({
2458
- key : value for key , value in kwargs .items ()
2459
- if key not in ('color' ,)
2460
- })
2477
+ # NOTE: Calling set_array is what triggers LineCollection to determine
2478
+ # colors using ScalarMappable and normalizer.
2479
+ kwargs .setdefault ('capstyle' , 'butt' )
2480
+ kwargs .setdefault ('joinstyle' , 'miter' )
2481
+ kwargs .setdefault ('linestyles' , '-' )
2482
+ mappable = mcollections .LineCollection (coords , ** kwargs )
2483
+ mappable .set_array (values )
2484
+ self .add_collection (mappable )
2485
+ self .autoscale_view (scalex = scalex , scaley = scaley )
2461
2486
2462
2487
# Add collection with some custom attributes
2463
2488
# NOTE: Modern API uses self._request_autoscale_view but this is
2464
2489
# backwards compatible to earliest matplotlib versions.
2465
- self . add_collection ( obj )
2466
- self . autoscale_view ( scalex = scalex , scaley = scaley )
2467
- obj . values = values
2468
- obj . levels = levels # needed for other functions
2469
- return obj
2490
+ mappable . values = values
2491
+ mappable . levels = levels # needed for other functions
2492
+ plot . _auto_colorbar ( mappable , ** kwargs_colorbar )
2493
+
2494
+ return mappable
2470
2495
2471
2496
@plot ._concatenate_docstrings
2472
2497
@docstring .add_snippets
@@ -2542,7 +2567,7 @@ def pie(self, *args, **kwargs):
2542
2567
# plot = _plot_wrapper(_standardize_1d(_indicate_error(_cycle_changer(
2543
2568
@plot ._concatenate_docstrings
2544
2569
@docstring .add_snippets
2545
- @plot ._add_autoformat
2570
+ @plot ._with_autoformat
2546
2571
def plot (self , * args , cmap = None , values = None , ** kwargs ):
2547
2572
"""
2548
2573
Parameters
@@ -2622,7 +2647,7 @@ def quiver(self, *args, **kwargs):
2622
2647
# scatter = _scatter_wrapper(_standardize_1d(_indicate_error(_cycle_changer(
2623
2648
@plot ._concatenate_docstrings
2624
2649
@docstring .add_snippets
2625
- @plot ._add_autoformat
2650
+ @plot ._with_autoformat
2626
2651
def scatter (
2627
2652
self , * args ,
2628
2653
s = None , size = None , markersize = None ,
0 commit comments