@@ -696,7 +696,7 @@ def _plot_redirect(self, name, *args, **kwargs):
696696 if getattr (self , 'name' , '' ) == 'basemap' :
697697 return getattr (self .projection , name )(* args , ax = self , ** kwargs )
698698 else :
699- return getattr (maxes . Axes , name )(self , * args , ** kwargs )
699+ return getattr (super () , name )(self , * args , ** kwargs )
700700
701701 def _range_gridspec (self , x ):
702702 """
@@ -1244,7 +1244,7 @@ def areax(self, *args, **kwargs):
12441244 # bar = _bar_wrapper(_standardize_1d(_indicate_error(_cycle_changer(
12451245 @plot ._concatenate_docstrings
12461246 @docstring .add_snippets
1247- @plot ._add_autoformat
1247+ @plot ._with_autoformat
12481248 def bar (
12491249 self , x = None , height = None , width = 0.8 , bottom = None , * ,
12501250 vert = None , orientation = 'vertical' , stacked = False ,
@@ -1268,6 +1268,23 @@ def bar(
12681268 kwargs , kwargs_legend_colorbar = plot ._parse_cycle (** kwargs )
12691269 kwargs , kwargs_error = plot ._parse_error (** kwargs )
12701270
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+
12711288 # Parse args
12721289 # TODO: Stacked feature is implemented in `cycle_changer`, but makes more
12731290 # sense do document here; figure out way to move it here?
@@ -1369,7 +1386,7 @@ def boxes(self, *args, **kwargs):
13691386 # boxplot = _boxplot_wrapper(_standardize_1d(_cycle_changer(
13701387 @plot ._concatenate_docstrings
13711388 @docstring .add_snippets
1372- @plot ._add_autoformat
1389+ @plot ._with_autoformat
13731390 def boxplot (
13741391 self , * args ,
13751392 color = 'k' , fill = True , fillcolor = None , fillalpha = 0.7 ,
@@ -1716,10 +1733,19 @@ def contour(self, *args, **kwargs):
17161733 %(plot.auto_colorbar)s
17171734 %(plot.cmap_args)s
17181735 """
1736+ # Parse arguments
17191737 args = plot ._parse_2d (* args )
17201738 kwargs , kwargs_colorbar = plot ._parse_cmap (** kwargs )
1739+ kwargs , kwargs_label = plot ._parse_labels (** kwargs )
1740+
1741+ # Call main function
17211742 mappable = self ._plot_redirect ('contour' , * args , ** kwargs )
1743+
1744+ # Post-processing
1745+ plot ._auto_contour_labels (mappable , ** kwargs_label )
17221746 plot ._auto_colorbar (mappable , ** kwargs_colorbar )
1747+ plot ._edgefix_contour (mappable )
1748+
17231749 return mappable
17241750
17251751 @plot ._concatenate_docstrings
@@ -1840,7 +1866,7 @@ def _fill_between_apply(
18401866
18411867 @plot ._concatenate_docstrings
18421868 @docstring .add_snippets
1843- @plot ._add_autoformat
1869+ @plot ._with_autoformat
18441870 def fill_between (self , * args , ** kwargs ):
18451871 """
18461872 %(axes.fill_between)s
@@ -1849,7 +1875,7 @@ def fill_between(self, *args, **kwargs):
18491875
18501876 @plot ._concatenate_docstrings
18511877 @docstring .add_snippets
1852- @plot ._add_autoformat
1878+ @plot ._with_autoformat
18531879 def fill_betweenx (self , * args , ** kwargs ):
18541880 """
18551881 %(axes.fill_betweenx)s
@@ -1934,7 +1960,7 @@ def hexbin(self, *args, **kwargs):
19341960 # hist = _hist_wrapper(_standardize_1d(_cycle_changer(
19351961 @plot ._concatenate_docstrings
19361962 @docstring .add_snippets
1937- @plot ._add_autoformat
1963+ @plot ._with_autoformat
19381964 def hist (self , x , bins = None , ** kwargs ):
19391965 """
19401966 Add histogram(s).
@@ -2395,7 +2421,7 @@ def parametric(
23952421 )
23962422 else :
23972423 raise ValueError ('Missing required keyword argument "values".' )
2398- cmap , norm , kwargs = plot ._parse_cmap_norm (** kwargs )
2424+ kwargs , kwargs_colorbar = plot ._parse_cmap (** kwargs )
23992425
24002426 # Verify shapes
24012427 x , y , values = np .atleast_1d (x ), np .atleast_1d (y ), np .atleast_1d (values )
@@ -2446,27 +2472,26 @@ def parametric(
24462472 coords .append (np .concatenate ((pleft , pright ), axis = 0 ))
24472473 coords = np .array (coords )
24482474
2449- # Create LineCollection and update with values
2475+ # Add LineCollection and update with values
24502476 # 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 )
24612486
24622487 # Add collection with some custom attributes
24632488 # NOTE: Modern API uses self._request_autoscale_view but this is
24642489 # 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
24702495
24712496 @plot ._concatenate_docstrings
24722497 @docstring .add_snippets
@@ -2542,7 +2567,7 @@ def pie(self, *args, **kwargs):
25422567 # plot = _plot_wrapper(_standardize_1d(_indicate_error(_cycle_changer(
25432568 @plot ._concatenate_docstrings
25442569 @docstring .add_snippets
2545- @plot ._add_autoformat
2570+ @plot ._with_autoformat
25462571 def plot (self , * args , cmap = None , values = None , ** kwargs ):
25472572 """
25482573 Parameters
@@ -2622,7 +2647,7 @@ def quiver(self, *args, **kwargs):
26222647 # scatter = _scatter_wrapper(_standardize_1d(_indicate_error(_cycle_changer(
26232648 @plot ._concatenate_docstrings
26242649 @docstring .add_snippets
2625- @plot ._add_autoformat
2650+ @plot ._with_autoformat
26262651 def scatter (
26272652 self , * args ,
26282653 s = None , size = None , markersize = None ,
0 commit comments