Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add EventCollection and eventplot #1657

merged 0 commits into from

5 participants


As discussed in the mailing list, here is the event plot. It's purpose it to plot one or more series of 1D data points along horizontal or vertical lines. It is dived into two parts.

The first part is the EventCollection collections class, which is a subclass of LineCollection that makes it easy to create and manipulate individual rows of vertical lines or columns of horizontal lines. Besides being used in the final plot type, this is also useful on its own, for example for marking the locations of data points along an axis (see Besides the convenience functions, since it is a subclass of LineCollection it also exposes all internal LineCollection and Collection methods, allowing more fine-grained modifications for artists.

The second part is an axes method (also in pyplot through which is given one or more rows of data points and creates corresponding rows or columns of lines. All rows or columns can be given the same line properties or individual line properties (see It returns a list of EventCollection objects.

Tests for both EventCollection and eventplot are present, and the files have been tested for pep8 compliance and run through pyflakes and pylint and fixed wherever appropriate.

((103 lines not shown))
+ if len(lineoffsets) == 1:
+ lineoffsets = np.tile(lineoffsets, len(positions))
+ lineoffsets[0] = 0
+ lineoffsets = np.cumsum(lineoffsets)
+ if len(linelengths) == 1:
+ linelengths = np.tile(linelengths, len(positions))
+ if len(linewidths) == 1:
+ linewidths = np.tile(linewidths, len(positions))
+ if len(colors) == 1:
+ colors = np.asanyarray(colors)
+ colors = np.tile(colors, [len(positions), 1])
+ if len(linestyles) == 1:
+ linestyles = [linestyles] * len(positions)
+ if len(lineoffsets) != len(positions):
+ raise ValueError('lineoffsets and positions are unequal sized \
@NelleV Collaborator
NelleV added a note

Minor nitpick: this way of setting strings will indent the output in a weird way. There are several ways to avoid this, my favourite being:

raise ValueError("lineoffsets and positions are unequal sized "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

You don't need to commit the png versions of the svg and pdf files. Please remove the files that end in "_pdf.png" and "_svg.png".


Very nice patch ! Both the code and documentation are very clear and very clean.


I have made the recommended changes


One remaining issue is all the whitespace in the generated pyplot code. Should that be left in, removed manually, or should I modify to remove it automatically?

I already have a modified version of that strips all trailing spaces automatically, I could commit it if that is the best approach.


I'd be pro modifying to remove extra whitespace automatically, but let's not do it as part of this PR. Best to just include the generated code as it is for this PR, then we can fix and commit a cleaner along with it.


I agree with @mdboom, with the view that modifying to produce PEP8 compliant code would be the end goal.


@toddrjen Unfortunately, you'll need to rebase this against current master so that it will merge cleanly.

@toddrjen toddrjen merged commit 39384a5 into matplotlib:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 0 additions and 0 deletions.
Something went wrong with that request. Please try again.