X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,10 +1110,12 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
"vertical' : lines will be horizontal and arranged in columns

*lineoffsets* :
A float or array-like containing floats.
A float or array-like containing floats. If a zero length array,
defaults to 0.

*linelengths* :
A float or array-like containing floats.
A float or array-like containing floats. If a zero length array,
defaults to 1.

*linewidths* :
A float or array-like containing floats.
Expand All @@ -1124,7 +1126,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,

*linestyles* :
[ 'solid' | 'dashed' | 'dashdot' | 'dotted' ] or an array of these
values
values. If a zero length array, defaults to 'solid'.

For linelengths, linewidths, colors, and linestyles, if only a single
value is given, that value is applied to all lines. If an array-like
Expand Down Expand Up @@ -1183,13 +1185,13 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
linewidths = np.asarray(linewidths)

if len(lineoffsets) == 0:
lineoffsets = [None]
lineoffsets = [0]
if len(linelengths) == 0:
linelengths = [None]
if len(linewidths) == 0:
lineoffsets = [None]
linelengths = [1]
if len(linewidths) == 0:
lineoffsets = [None]
linewidths = [None]
if len(linestyles) == 0:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why to do this for symmetry, but this is a odd special case. Why would you pass in an empty list to get the default behavior?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess one could also ask why one would want to pass an empty list to get the default for any of the earlier parameters... (unless there's a compelling reason, we should get rid of that behavior :-))

linestyles = ['solid']
if len(colors) == 0:
colors = [None]

Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,13 @@ def test_empty_eventplot():
plt.draw()


@cleanup
def test_eventplot_empty_args():
fig, ax = plt.subplots()
ax.eventplot([1, 2, 3], lineoffsets=[], linelengths=[], linewidths=[],
linestyles=[], colors=[])


@image_comparison(baseline_images=['marker_styles'], extensions=['png'], remove_text=True)
def test_marker_styles():
fig = plt.figure()
Expand Down
X Tutup