Add stairstep plotting functionality #1068

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants
Member

dmcdougall commented Aug 10, 2012

This feature replicates Matlab's `stairs' function to produce stairstep
type plots. These plots are useful for plots in signal processing for
looking at discretely sampled data. Valid function calls are

ax.stairs(y) # Make a stairstep plot of the values in y
ax.stairs(x, y) # Stairstep plot of the values in y at points in x

See here for the Matlab interface.

Example output:

example output

dmcdougall added some commits Aug 10, 2012

@dmcdougall dmcdougall Add stairstep plotting functionality
This feature replicates Matlab's `stairs' function to produce stairstep
type plots. These plots are useful for plots in signal processing for
looking at discretely sampled data. Valid function calls are

stairs(y) # Make a stairstep plot of the values in y
stairs(x, y) # Stairstep plot of the values in y at points in x
861190a
@dmcdougall dmcdougall Add stairstep plot example c5c4dca
Member

dmcdougall commented Aug 10, 2012

I did not know this existed!

Damon McDougall
d.mcdougall@warwick.ac.uk
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

On Friday, 10 August 2012 at 19:20, Eric Firing wrote:

How does this differ from step?
http://matplotlib.sourceforge.net/examples/pylab_examples/step_demo.html


Reply to this email directly or view it on GitHub (#1068 (comment)).

@WeatherGod WeatherGod commented on the diff Aug 10, 2012

lib/matplotlib/stairs.py
@@ -0,0 +1,45 @@
+"""
+Stairstep plots.
+"""
+
+import numpy as np
+
+__all__ = ['stairs']
+
+def stairs(axes, *args, **kwargs):
@WeatherGod

WeatherGod Aug 10, 2012

Member

To be consistent with the rest of the code-base, I would change "axes" to "ax"

@WeatherGod WeatherGod commented on the diff Aug 10, 2012

lib/matplotlib/stairs.py
@@ -0,0 +1,45 @@
+"""
+Stairstep plots.
+"""
+
+import numpy as np
+
+__all__ = ['stairs']
+
+def stairs(axes, *args, **kwargs):
+ """Draws a stairstep plot
@WeatherGod

WeatherGod Aug 10, 2012

Member

Put the triple quote on its own line.

Member

dmcdougall commented Aug 10, 2012

This should probably be closed since it already exists, as @efiring pointed out. Unless anybody disagrees? It seems moot to duplicate existing functionality.

Owner

mdboom commented Aug 10, 2012

Well, perhaps the meta question is: what made it difficult for @dmcdougall to find the existing functionality, and how could that be improved? Maybe we need a patch for that...

Owner

efiring commented Aug 10, 2012

We do, and Ben started on at least part of the solution, which is putting some organization and editing into the gallery. There is only one step example, and it is burried in the middle; I had to scan the gallery twice to find it, and if I hadn't been pretty sure it was there, I would likely have missed it.

Member

dmcdougall commented Aug 10, 2012

I went to the matplotlib homepage, and did a command-f for stairs (because someone on the mailing list was asking how to make stairstep plots).

Also, step is not on the list on the homepage either.

Perhaps re-naming step to stairs (or wrapping it, so people's scripts don't break) so the Matlab and matplotlib naming conventions are more aligned would be useful to avoid future confusion. Or, adding step to the homepage so it can be found more easily.

Owner

mdboom commented Aug 10, 2012

Yeah -- that list on the homepage was manually generated many versions ago, so it's incomplete. As part of my reorganization of the front page in #1067 I'm proposing to just get rid of it and funnel people to the pyplot documentation instead. Not sure that's the best solution either, as some people surely find that list useful.

Member

dmcdougall commented Aug 10, 2012

I use it every day. I command-f the function I want so I can look at the docs. I always have to check it to remind myself, for example, which element of the extent kwarg list in imshow refers to which bound.

Member

pelson commented Aug 11, 2012

@mdboom: Maybe a similar table to the one that currently exists could be autogenerated and the content come from the autosummary extension.

Owner

efiring commented Aug 13, 2012

There is useful discussion here, but as a pull request, this really needs to be closed.

efiring closed this Aug 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment