Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add EventCollection and eventplot #1657

Merged
merged 0 commits into from

5 participants

@toddrjen

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 eventcollection_demo.py). 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 boilerplate.py) 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 eventplot_demo.py). 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.

lib/matplotlib/axes.py
((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 "
                 "sequences.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@WeatherGod
Collaborator

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".

@toddrjen
@NelleV
Collaborator

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

@toddrjen
@toddrjen

I have made the recommended changes

@toddrjen

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

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

@mdboom
Owner

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

@dmcdougall
Collaborator

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

@toddrjen
@dmcdougall
Collaborator

@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.