-
Notifications
You must be signed in to change notification settings - Fork 25
feat: PlottableProtocol support #476
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
Changes from all commits
96019fb
c28f346
5f58c9c
2185e49
ae1d2fb
de0318c
6620677
3b38811
f0eccd0
eeab0c4
de1c29c
0ba2352
78e4d08
5fe0961
6a70bbf
e56bf95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| .. _usage-plotting: | ||
|
|
||
| Plotting | ||
| ======== | ||
|
|
||
| Boost-histogram does not contain plotting functions - this is outside of the | ||
| scope of the project, which is histogram filling and manipulation. However, it | ||
| does follow ``PlottableProtocol``, as listed below. Any plotting library that | ||
| accepts an object that follows the ``PlottableProtocol`` can plot boost-histogram | ||
| objects. | ||
|
|
||
| Using the protocol: | ||
|
|
||
| Plotters should only depend on the methods and attributes listed below. In short, they are: | ||
|
|
||
| * ``h.kind``: The ``bh.Kind`` of the histogram (COUNT or MEAN) | ||
| * ``h.values()``: The value (as given by the kind) | ||
| * ``h.variances()``: The variance in the value (None if an unweighed histogram was filled with weights) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wording is not correct, because .variances() does not give you the variance of the mean if kind == MEAN it gives the variances of the samples. You need to divide that by .counts() to get the variance of the mean.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we decided in the PlottableProtocol that I could easily be wrong here, though, either/both about what we decided and what is best. @jpivarski what does Uproot return for |
||
| * ``h.counts()``: How many fills the bin received or the effective number of fills if the histogram is weighted | ||
| * ``h.axes``: A Sequence of axes | ||
|
|
||
| Axes have: | ||
|
|
||
| * ``ax[i]``: A sequence of lower, upper bin, or the discrete bin value (integer or sting) | ||
| * ``len(ax)``: The number of bins | ||
| * ``ax.traits.circular``: True if circular | ||
| * ``ax.traits.discrete``: True if the bin represents a single value (e.g. Integer or Category axes) instead of an interval (e.g. Regular or Variable axes) | ||
|
|
||
| Plotters should see if ``.counts()`` is None; no boost-histogram objects currently | ||
| return None, but a future storage or different library could. | ||
|
|
||
| Also check ``.variances``; if not None, this storage holds variance information and | ||
| error bars should be included. Boost-histogram histograms will return something | ||
| unless they know that this is an invalid assumption (a weighted fill was made | ||
| on an unweighted histogram). | ||
|
|
||
| The full protocol version 1 follows: | ||
|
|
||
| .. literalinclude:: ../../tests/plottable.py | ||
| :language: python | ||
Uh oh!
There was an error while loading. Please reload this page.