Skip to content

Commit

Permalink
ENH : add flag to box_plot and bxp to manage (or not) xticks
Browse files Browse the repository at this point in the history
  • Loading branch information
tacaswell committed Mar 24, 2014
1 parent 76f902c commit f594eb3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -2854,7 +2854,7 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
bootstrap=None, usermedians=None, conf_intervals=None,
meanline=False, showmeans=False, showcaps=True,
showbox=True, showfliers=True, boxprops=None, labels=None,
flierprops=None, medianprops=None, meanprops=None):
flierprops=None, medianprops=None, meanprops=None, manage_xticks=True):
"""
Make a box and whisker plot.
Expand Down Expand Up @@ -3039,14 +3039,15 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
showcaps=showcaps, showbox=showbox,
boxprops=boxprops, flierprops=flierprops,
medianprops=medianprops, meanprops=meanprops,
meanline=meanline, showfliers=showfliers)
meanline=meanline, showfliers=showfliers,
manage_xticks=manage_xticks)
return artists

def bxp(self, bxpstats, positions=None, widths=None, vert=True,
patch_artist=False, shownotches=False, showmeans=False,
showcaps=True, showbox=True, showfliers=True,
boxprops=None, flierprops=None, medianprops=None,
meanprops=None, meanline=False):
meanprops=None, meanline=False, manage_xticks=True):
"""
Drawing function for box and whisker plots.
Expand All @@ -3056,7 +3057,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
patch_artist=False, shownotches=False, showmeans=False,
showcaps=True, showbox=True, showfliers=True,
boxprops=None, flierprops=None, medianprops=None,
meanprops=None, meanline=False)
meanprops=None, meanline=False, manage_xticks=True)
Make a box and whisker plot for each column of *x* or each
vector in sequence *x*. The box extends from the lower to
Expand Down Expand Up @@ -3135,6 +3136,9 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
*meanprops*. Not recommended if *shownotches* is also True.
Otherwise, means will be shown as points.
manage_xticks : bool, default = True
If the function should adjust the xlim and xtick locations.
Returns
-------
Expand Down Expand Up @@ -3369,10 +3373,11 @@ def dopatch(xs, ys, **kwargs):
setlim = self.set_ylim
setlabels = self.set_yticklabels

newlimits = min(positions) - 0.5, max(positions) + 0.5
setlim(newlimits)
setticks(positions)
setlabels(datalabels)
if manage_xticks:
newlimits = min(positions) - 0.5, max(positions) + 0.5
setlim(newlimits)
setticks(positions)
setlabels(datalabels)

# reset hold status
self.hold(holdStatus)
Expand Down

0 comments on commit f594eb3

Please sign in to comment.