8000 Changed orientation variable to string from boolean · matplotlib/matplotlib@a1ebd1f · GitHub
[go: up one dir, main page]

Skip to content

Commit a1ebd1f

Browse files
ItsRLuoQuLogic
authored andcommitted
Changed orientation variable to string from boolean
Also modified documentation for the change. Flipped thisx to thisy and vice versa when the orientation value is vertical
1 parent 7f10300 commit a1ebd1f

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,7 @@ def broken_barh(self, xranges, yrange, **kwargs):
27232723

27242724
@_preprocess_data()
27252725
def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2726-
label=None, use_line_collection=True, vertical=False):
2726+
label=None, use_line_collection=True, orientation='horizontal'):
27272727
"""
27282728
Create a stem plot.
27292729
@@ -2774,8 +2774,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
27742774
basefmt : str, default: 'C3-' ('C2-' in classic mode)
27752775
A format string defining the properties of the baseline.
27762776
2777-
vertical : bool, optional (False)
2778-
If 'True', will produce a vertically-oriented stem plot.
2777+
orientation : string, optional (horizontal)
2778+
If 'vertical', will produce a vertically-oriented stem plot,
2779+
else it will produce a horizontally-oriented stem plot.
27792780
27802781
bottom : float, default: 0
27812782
The y-position of the baseline.
@@ -2866,12 +2867,12 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
28662867
basestyle, basemarker, basecolor = _process_plot_format(basefmt)
28672868

28682869
# Check if the user wants a vertical stem plot
2869-
if vertical:
2870+
if orientation == 'vertical':
28702871
x, y = y, x
28712872

28722873
# New behaviour in 3.1 is to use a LineCollection for the stemlines
28732874
if use_line_collection:
2874-
if vertical:
2875+
if orientation == 'vertical':
28752876
stemlines = [((bottom, yi), (xi, yi)) for xi, yi in zip(x, y)]
28762877
else:
28772878
stemlines = [((xi, bottom), (xi, yi)) for xi, yi in zip(x, y)]
@@ -2885,7 +2886,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
28852886
else:
28862887
stemlines = []
28872888
for xi, yi in zip(x, y):
2888-
if vertical:
2889+
if orientation == 'vertical':
28892890
xs = [bottom, xi]
28902891
ys = [yi, yi]
28912892
else:
@@ -2898,7 +2899,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
28982899

28992900
markerline, = self.plot(x, y, color=markercolor, linestyle=markerstyle,
29002901
marker=markermarker, label="_nolegend_")
2901-
if vertical:
2902+
2903+
if orientation == 'vertical':
2904+
x, y = y, x
29022905
baseline, = self.plot([bottom, bottom], [np.min(x), np.max(x)],
29032906
color=basecolor, linestyle=basestyle,
29042907
marker=basemarker, label="_nolegend_")

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,12 +3018,13 @@ def stackplot(
30183018
@_copy_docstring_and_deprecators(Axes.stem)
30193019
def stem(
30203020
*args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
3021-
label=None, use_line_collection=True, vertical=False,
3022-
data=None):
3021+
label=None, use_line_collection=True,
3022+
orientation='horizontal', data=None):
30233023
return gca().stem(
30243024
*args, linefmt=linefmt, markerfmt=markerfmt, basefmt=basefmt,
30253025
bottom=bottom, label=label,
3026-
use_line_collection=use_line_collection, vertical=vertical,
3026+
use_line_collection=use_line_collection,
3027+
orientation=orientation,
30273028
**({"data": data} if data is not None else {}))
30283029

30293030

0 commit comments

Comments
 (0)
0