In [1]:
from __future__ import print_function
import pytest
import os, sys
import numpy as np
sys.path.insert(0, os.path.abspath('../../..'))
import hublib.rappture as rappture
from hublib import ureg, Q_
This code loads in the output of a run from the Rappture zoo of examples.
https://nanohub.org/infrastructure/rappture/browser/trunk/examples/zoo/histogram
In [2]:
io = rappture.RapXML('hist_run.xml')
In [3]:
io
Out[3]:
In [4]:
%matplotlib notebook
io['output.histogram(example)'].plot()
Here is what Rappture outputs:
In [5]:
io['output.histogram(example)'].xml()
Out[5]:
In [6]:
io['output.histogram(single)'].plot()
Here is Rappture's output for the same data:
Just like Curves, Histograms can have a group id, so they can be plotted together. Here they are seperated
In [7]:
import matplotlib.pyplot as plt
fig, axs = plt.subplots(1,2)
io['output.histogram(multi1.8)'].plot(single=True, ax=axs[0])
io['output.histogram(multi2)'].plot(single=True, ax=axs[1])
Plot them both together like this:
In [8]:
io['output.histogram(multi2)'].plot()
If you prefer them stacked...
In [9]:
io['output.histogram(multi2)'].plot(stacked=True)
Here is what Rappture does, which seems VERY wrong. It looks like a stacked barchart, but the heights do not add up. Its behavior for multiple histograms is actually not documented, so maybe it is a feature. This example is from the zoo examples.
In [10]:
io['output.histogram(namevalue)'].plot(horizontal=True)
In [11]:
io['output.histogram(width)'].plot()