-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Port part of errorfill from Tony Yu's mpltools. #1010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Specifically, the function `extrema_from_error_input` from https://github.com/tonysyu/mpltools/blob/master/mpltools/special/errorfill.py#L54 is ported to matplotlib.mlab.
xmin = x - xerr | ||
xmax = x + xerr | ||
elif len(xerr) == 2: | ||
xmin, xmax = x - xerr[0], x + xerr[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the undefined case (not a scalar, nor len in [2, n])?
Coming at this fresh, why is this called I could see this function being useful for handling numpy arrays, which makes me wonder whether it would be better to put this straight into numpy rather than mlab? |
Renamed *x* to *y*.
Utilises cbook.is_numlike, etc.
@pelson I have no idea! It seemed natural given the example in the docstring. How about |
@pelson re numpy vs mlab: if we have something that is useful to people I like to ship it so that our code works across multiple versions of numpy. If numpy wants something from mlab, or someone wants to push to get it into numpy, that's great, but I'd like to have it in several release cycles of numpy before we stop shipping it. We've done this with a ton of mlab functions over the years and it doesn't seem to have caused many problems. This function in particular is mainly a convenience method for fill_between -- I don't see it being generically useful enough to make it into numpy. |
o A tuple of length 2. In this case, yerr[0] is the error below *y* and | ||
yerr[1] is error above *y*. | ||
|
||
For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My memory is a little haze, but if you put a double colon, and then indent the code, you will get a pretty code block if/when rendered with Sphinx.
o A tuple of length 2. In this case, yerr[0] is the error below *y* and | ||
yerr[1] is error above *y*. | ||
|
||
.. For example:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "For"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the leading ..
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep getting sphinx syntax mixed up in my head. A directive is made up of a leading double dots, a space and a single word followed by double colons. Any arguments for that directive follow the double colons. "keyword" arguments (if any) are provided on the subsequent indented lines with the name of the keyword surrounded by colons and the value after it (see doc/api/index.rst for an example). Finally, any remaining indented text is treated as-is as a large string block.
It doesn't look like there is an ".. example::" directive, so I would re-write this part of the docstring as:
yerr[1] is error above *y*. For example::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WeatherGod Where do I put the double dots in your example?
I followed the example below (from pyplot.py
):
def figlegend(handles, labels, loc, **kwargs):
"""
Place a legend in the figure.
*labels*
a sequence of strings
*handles*
a sequence of :class:`~matplotlib.lines.Line2D` or
:class:`~matplotlib.patches.Patch` instances
*loc*
can be a string or an integer specifying the legend
location
A :class:`matplotlib.legend.Legend` instance is returned.
Example::
figlegend( (line1, line2, line3),
('label1', 'label2', 'label3'),
'upper right' )
.. seealso::
:func:`~matplotlib.pyplot.legend`
"""
l = gcf().legend(handles, labels, loc, **kwargs)
draw_if_interactive()
return l
I don't have sphinx, and I have no experience with it, so I'm deferring to you guys for epic sphinxage :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't. Whenever you want to display a code block, you use just double-colons and indent the code block. You might also have to have a blank line as well. The word "example" before the double-colons is not special and can be any word. Sometimes, we even just use double colons on a line all by itself.
Ok, there is no reason for this not to make it into 1.2.x so I have updated the milestone. |
@dmcdougall : Do you consider this ready to merge? |
@mdboom Sounds good to me. Thanks for the feedback. |
Port part of errorfill from Tony Yu's mpltools.
Specifically, the function
extrema_from_error_input
fromhttps://github.com/tonysyu/mpltools/blob/master/mpltools/special/errorfill.py#L54
is ported to matplotlib.mlab.