diff --git a/doc/api/api_changes_3.3/deprecations.rst b/doc/api/api_changes_3.3/deprecations.rst index adf6337deca9..ab3b3323030a 100644 --- a/doc/api/api_changes_3.3/deprecations.rst +++ b/doc/api/api_changes_3.3/deprecations.rst @@ -460,3 +460,8 @@ of `.ScalarMappable` are deprecated. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All parameters of ``ColorbarBase``, except for the first (*ax*), will become keyword-only, consistently with ``Colorbar``. + +`.Axes.pie` radius and startangle +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Passing ``None`` as either the ``radius`` or ``startangle`` of an `.Axes.pie` +is deprecated; use the explicit defaults of 1 and 0, respectively, instead. diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 3f9d7fede100..35fd2b0ce890 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2899,7 +2899,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, @_preprocess_data(replace_names=["x", "explode", "labels", "colors"]) def pie(self, x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, - startangle=None, radius=None, counterclock=True, + startangle=0, radius=1, counterclock=True, wedgeprops=None, textprops=None, center=(0, 0), frame=False, rotatelabels=False): """ @@ -2932,7 +2932,7 @@ def pie(self, x, explode=None, labels=None, colors=None, autopct : None or str or callable, default: None If not *None*, is a string or function used to label the wedges with their numeric value. The label will be placed inside the - wedge. If it is a format string, the label will be ``fmt%pct``. + wedge. If it is a format string, the label will be ``fmt % pct``. If it is a function, it will be called. pctdistance : float, default: 0.6 @@ -2947,12 +2947,12 @@ def pie(self, x, explode=None, labels=None, colors=None, If set to ``None``, label are not drawn, but are stored for use in ``legend()`` - startangle : float, default: None - If not *None*, rotates the start of the pie chart by *angle* - degrees counterclockwise from the x-axis. + startangle : float, default: 0 degrees + The angle by which the start of the pie is rotated, + counterclockwise from the x-axis. - radius : float, default: None - The radius of the pie, if *radius* is *None* it will be set to 1. + radius : float, default: 1 + The radius of the pie. counterclock : bool, default: True Specify fractions direction, clockwise or counterclockwise. @@ -3030,22 +3030,25 @@ def get_next_color(): return next(color_cycle) if radius is None: + cbook.warn_deprecated( + "3.3", message="Support for passing a radius of None to mean " + "1 is deprecated since %(since)s and will be removed " + "%(removal)s.") radius = 1 # Starting theta1 is the start fraction of the circle if startangle is None: - theta1 = 0 - else: - theta1 = startangle / 360.0 + cbook.warn_deprecated( + "3.3", message="Support for passing a startangle of None to " + "mean 0 is deprecated since %(since)s and will be removed " + "%(removal)s.") + startangle = 0 + theta1 = startangle / 360 - # set default values in wedge_prop if wedgeprops is None: wedgeprops = {} - wedgeprops.setdefault('clip_on', False) - if textprops is None: textprops = {} - textprops.setdefault('clip_on', False) texts = [] slices = [] @@ -3061,18 +3064,17 @@ def get_next_color(): w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2), 360. * max(theta1, theta2), facecolor=get_next_color(), - **wedgeprops) + clip_on=False, + label=label) + w.set(**wedgeprops) slices.append(w) self.add_patch(w) - w.set_label(label) if shadow: - # make sure to add a shadow after the call to - # add_patch so the figure and transform props will be - # set + # Make sure to add a shadow after the call to add_patch so the + # figure and transform props will be set. shad = mpatches.Shadow(w, -0.02, -0.02) - shad.set_zorder(0.9 * w.get_zorder()) - shad.set_label('_nolegend_') + shad.set(zorder=0.9 * w.get_zorder(), label='_nolegend_') self.add_patch(shad) if labeldistance is not None: @@ -3085,14 +3087,13 @@ def get_next_color(): label_alignment_v = 'bottom' if yt > 0 else 'top' label_rotation = (np.rad2deg(thetam) + (0 if xt > 0 else 180)) - props = dict(horizontalalignment=label_alignment_h, - verticalalignment=label_alignment_v, - rotation=label_rotation, - size=rcParams['xtick.labelsize']) - props.update(textprops) - - t = self.text(xt, yt, label, **props) - + t = self.text(xt, yt, label, + clip_on=False, + horizontalalignment=label_alignment_h, + verticalalignment=label_alignment_v, + rotation=label_rotation, + size=rcParams['xtick.labelsize']) + t.set(**textprops) texts.append(t) if autopct is not None: @@ -3105,25 +3106,19 @@ def get_next_color(): else: raise TypeError( 'autopct must be callable or a format string') - - props = dict(horizontalalignment='center', - verticalalignment='center') - props.update(textprops) - t = self.text(xt, yt, s, **props) - + t = self.text(xt, yt, s, + clip_on=False, + horizontalalignment='center', + verticalalignment='center') + t.set(**textprops) autotexts.append(t) theta1 = theta2 if not frame: - self.set_frame_on(False) - - self.set_xlim((-1.25 + center[0], - 1.25 + center[0])) - self.set_ylim((-1.25 + center[1], - 1.25 + center[1])) - self.set_xticks([]) - self.set_yticks([]) + self.set(frame_on=False, xticks=[], yticks=[], + xlim=(-1.25 + center[0], 1.25 + center[0]), + ylim=(-1.25 + center[1], 1.25 + center[1])) if autopct is None: return slices, texts diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 27c8f03d27c3..4aa2f8023e13 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2648,8 +2648,8 @@ def phase_spectrum( def pie( x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, - startangle=None, radius=None, counterclock=True, - wedgeprops=None, textprops=None, center=(0, 0), frame=False, + startangle=0, radius=1, counterclock=True, wedgeprops=None, + textprops=None, center=(0, 0), frame=False, rotatelabels=False, *, data=None): return gca().pie( x, explode=explode, labels=labels, colors=colors,
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: