Skip to content

Commit bdda1d5

Browse files
committed
ENH : add flag to box_plot and bxp to manage (or not) xticks
Closes #2921
1 parent 76f902c commit bdda1d5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/matplotlib/axes/_axes.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -2854,7 +2854,8 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
28542854
bootstrap=None, usermedians=None, conf_intervals=None,
28552855
meanline=False, showmeans=False, showcaps=True,
28562856
showbox=True, showfliers=True, boxprops=None, labels=None,
2857-
flierprops=None, medianprops=None, meanprops=None):
2857+
flierprops=None, medianprops=None, meanprops=None,
2858+
manage_xticks=True):
28582859
"""
28592860
Make a box and whisker plot.
28602861
@@ -3039,14 +3040,15 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
30393040
showcaps=showcaps, showbox=showbox,
30403041
boxprops=boxprops, flierprops=flierprops,
30413042
medianprops=medianprops, meanprops=meanprops,
3042-
meanline=meanline, showfliers=showfliers)
3043+
meanline=meanline, showfliers=showfliers,
3044+
manage_xticks=manage_xticks)
30433045
return artists
30443046

30453047
def bxp(self, bxpstats, positions=None, widths=None, vert=True,
30463048
patch_artist=False, shownotches=False, showmeans=False,
30473049
showcaps=True, showbox=True, showfliers=True,
30483050
boxprops=None, flierprops=None, medianprops=None,
3049-
meanprops=None, meanline=False):
3051+
meanprops=None, meanline=False, manage_xticks=True):
30503052
"""
30513053
Drawing function for box and whisker plots.
30523054
@@ -3056,7 +3058,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
30563058
patch_artist=False, shownotches=False, showmeans=False,
30573059
showcaps=True, showbox=True, showfliers=True,
30583060
boxprops=None, flierprops=None, medianprops=None,
3059-
meanprops=None, meanline=False)
3061+
meanprops=None, meanline=False, manage_xticks=True)
30603062
30613063
Make a box and whisker plot for each column of *x* or each
30623064
vector in sequence *x*. The box extends from the lower to
@@ -3135,6 +3137,9 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
31353137
*meanprops*. Not recommended if *shownotches* is also True.
31363138
Otherwise, means will be shown as points.
31373139
3140+
manage_xticks : bool, default = True
3141+
If the function should adjust the xlim and xtick locations.
3142+
31383143
Returns
31393144
-------
31403145
@@ -3369,10 +3374,11 @@ def dopatch(xs, ys, **kwargs):
33693374
setlim = self.set_ylim
33703375
setlabels = self.set_yticklabels
33713376

3372-
newlimits = min(positions) - 0.5, max(positions) + 0.5
3373-
setlim(newlimits)
3374-
setticks(positions)
3375-
setlabels(datalabels)
3377+
if manage_xticks:
3378+
newlimits = min(positions) - 0.5, max(positions) + 0.5
3379+
setlim(newlimits)
3380+
setticks(positions)
3381+
setlabels(datalabels)
33763382

33773383
# reset hold status
33783384
self.hold(holdStatus)

0 commit comments

Comments
 (0)