8000 Updated violinplot. Removed pdf and svg test images. · matplotlib/matplotlib@01c3176 · GitHub
[go: up one dir, main page]

Skip to content

Commit 01c3176

Browse files
committed
Updated violinplot. Removed pdf and svg test images.
1 parent b8db6d2 commit 01c3176

31 files changed

+56
-20619
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6898,14 +6898,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
68986898
medians = []
68996899

69006900
# Collections to be returned
6901-
artists = {
6902-
'bodies': [],
6903-
'cmeans': None,
6904-
'cmaxes': None,
6905-
'cmins': None,
6906-
'cbars': None,
6907-
'cmedians': None
6908-
}
6901+
artists = {}
69096902

69106903
N = len(vpstats)
69116904
datashape_message = ("List of violinplot statistics and `{0}` "
@@ -6927,53 +6920,50 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
69276920
pmins = -0.25 * np.array(widths) + positions
69286921
pmaxes = 0.25 * np.array(widths) + positions
69296922

6930-
# Check hold status
6931-
if not self._hold:
6932-
self.cla()
6933-
hold_status = self._hold
6934-
69356923
# Check whether we are rendering vertically or horizontally
69366924
if vert:
69376925
fill = self.fill_betweenx
6938-
rlines = self.hlines
6939-
blines = self.vlines
6926+
perp_lines = self.hlines
6927+
par_lines = self.vlines
69406928
else:
69416929
fill = self.fill_between
6942-
rlines = self.vlines
6943-
blines = self.hlines
6930+
perp_lines = self.vlines
6931+
par_lines = self.hlines
69446932

69456933
# Render violins
6934+
bodies = []
69466935
for stats, pos, width in zip(vpstats, positions, widths):
69476936
# The 0.5 factor reflects the fact that we plot from v-p to
69486937
# v+p
69496938
vals = np.array(stats['vals'])
69506939
vals = 0.5 * width * vals / vals.max()
6951-
artists['bodies'] += [fill(stats['coords'],
6952-
-vals + pos,
6953-
vals + pos,
6954-
facecolor='y',
6955-
alpha=0.3)]
6940+
bodies += [fill(stats['coords'],
6941+
-vals + pos,
6942+
vals + pos,
6943+
facecolor='y',
6944+
alpha=0.3)]
69566945
means.append(stats['mean'])
69576946
mins.append(stats['min'])
69586947
maxes.append(stats['max'])
69596948
medians.append(stats['median'])
6949+
artists['bodies'] = bodies
69606950

69616951
# Render means
69626952
if showmeans:
6963-
artists['cmeans'] = rlines(means, pmins, pmaxes, colors='r')
6953+
artists['cmeans'] = perp_lines(means, pmins, pmaxes, colors='r')
69646954

69656955
# Render extrema
69666956
if showextrema:
6967-
artists['cmaxes'] = rlines(maxes, pmins, pmaxes, colors='r')
6968-
artists['cmins'] = rlines(mins, pmins, pmaxes, colors='r')
6969-
artists['cbars'] = blines(positions, mins, maxes, colors='r')
6957+
artists['cmaxes'] = perp_lines(maxes, pmins, pmaxes, colors='r')
6958+
artists['cmins'] = perp_lines(mins, pmins, pmaxes, colors='r')
6959+
artists['cbars'] = par_lines(positions, mins, maxes, colors='r')
69706960

69716961
# Render medians
69726962
if showmedians:
6973-
artists['cmedians'] = rlines(medians, pmins, pmaxes, colors='r')
6974-
6975-
# Reset hold
6976-
self.hold(hold_status)
6963+
artists['cmedians'] = perp_lines(medians,
6964+
pmins,
6965+
pmaxes,
6966+
colors='r')
69776967

69786968
return artists
69796969

lib/matplotlib/cbook.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,6 +2137,14 @@ def is_math_text(s):
21372137

21382138

21392139
def _reshape_2D(X):
2140+
"""
2141+
Converts a non-empty list or an ndarray of two or fewer dimensions
2142+
into a list of iterable objects so that in
2143+
2144+
for v in _reshape_2D(X):
2145+
2146+
v is iterable and can be used to instantiate a 1D array.
2147+
"""
21402148
if hasattr(X, 'shape'):
21412149
# one item
21422150
if len(X.shape) == 1:
Binary file not shown.

0 commit comments

Comments
 (0)
0