Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
# built documents.
#
# The short X.Y version.
version = "1.0.3"
version = "1.0.4"
# The full version, including alpha/beta/rc tags.
release = "1.0.3"
release = "1.0.4"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
7 changes: 7 additions & 0 deletions histogrammar/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def specialize(self):
except (ImportError, AttributeError):
pass
self.fill = FillMethod(self, self.fill)
self.plot = PlotMethod(self, self.plot)
return self

@staticmethod
Expand Down Expand Up @@ -179,14 +180,20 @@ def fill(self, datum, weight=1.0):
"""
raise NotImplementedError

def plot(self, httpServer=None, **parameters):
"""Generate a VEGA visualization and serve it via HTTP."""
raise NotImplementedError

def __getstate__(self):
state = dict(self.__dict__)
del state["fill"]
del state["plot"]
return state

def __setstate__(self, dict):
self.__dict__ = dict
self.fill = FillMethod(self, self.fill)
self.plot = PlotMethod(self, self.plot)

def copy(self):
"""Copy this container, making a clone with no reference to the original. """
Expand Down
12 changes: 6 additions & 6 deletions histogrammar/plot/bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import math

class HistogramMethods(object):
def bokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):
def plotbokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):

#glyphs
from bokeh.models.glyphs import Rect, Segment, Line, Patches, Arc
Expand Down Expand Up @@ -66,7 +66,7 @@ def bokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",li
return GlyphRenderer(glyph=glyph,data_source=source)

class SparselyHistogramMethods(object):
def bokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):
def plotbokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):

#glyphs
from bokeh.models.glyphs import Rect, Segment, Line, Patches, Arc
Expand Down Expand Up @@ -114,7 +114,7 @@ def bokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",li


class ProfileMethods(object):
def bokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):
def plotbokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):

#glyphs
from bokeh.models.glyphs import Rect, Segment, Line, Patches, Arc
Expand Down Expand Up @@ -166,7 +166,7 @@ class SparselyProfileMethods(object):
pass

class ProfileErrMethods(object):
def bokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):
def plotbokeh(self,glyphType="line",glyphSize=1,fillColor="red",lineColor="black",lineAlpha=1,fillAlpha=0.1,lineDash='solid'):

#glyphs
from bokeh.models.glyphs import Rect, Segment, Line, Patches, Arc
Expand Down Expand Up @@ -231,7 +231,7 @@ class StackedHistogramMethods(object):
fillAlphaDefaults = [0.1]*nMaxStacked
lineDashDefaults = ["solid"]*nMaxStacked

def bokeh(self,glyphTypes=glyphTypeDefaults,glyphSizes=glyphSizeDefaults,fillColors=fillColorDefaults,lineColors=lineColorDefaults,lineAlphas=lineAlphaDefaults,fillAlphas=fillAlphaDefaults,lineDashes = lineDashDefaults):
def plotbokeh(self,glyphTypes=glyphTypeDefaults,glyphSizes=glyphSizeDefaults,fillColors=fillColorDefaults,lineColors=lineColorDefaults,lineAlphas=lineAlphaDefaults,fillAlphas=fillAlphaDefaults,lineDashes = lineDashDefaults):
nChildren = len(self.children)-1

assert len(glyphSizes) >= nChildren
Expand All @@ -245,7 +245,7 @@ def bokeh(self,glyphTypes=glyphTypeDefaults,glyphSizes=glyphSizeDefaults,fillCol
stackedGlyphs = list()
#for ichild, p in enumerate(self.children,start=1):
for ichild in range(nChildren):
stackedGlyphs.append(self.children[ichild+1].bokeh(glyphTypes[ichild],glyphSizes[ichild],fillColors[ichild],lineColors[ichild],lineAlphas[ichild],fillAlphas[ichild],lineDashes[ichild]))
stackedGlyphs.append(self.children[ichild+1].plotbokeh(glyphTypes[ichild],glyphSizes[ichild],fillColors[ichild],lineColors[ichild],lineAlphas[ichild],fillAlphas[ichild],lineDashes[ichild]))

return stackedGlyphs

Expand Down
26 changes: 13 additions & 13 deletions histogrammar/plot/mpl.py → histogrammar/plot/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set2Dsparse(sparse, yminBin, ymaxBin, grid):
return grid

class HistogramMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
"""
name : title of the plot.
kwargs : `matplotlib.patches.Rectangle` properties.
Expand All @@ -68,7 +68,7 @@ def matplotlib(self, name=None, **kwargs):
return ax

class SparselyHistogramMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
"""
name : title of the plot.
kwargs : `matplotlib.patches.Rectangle` properties.
Expand All @@ -95,7 +95,7 @@ def matplotlib(self, name=None, **kwargs):
return ax

class ProfileMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
""" Plotting method for Bin of Average
name : title of the plot.
kwargs : matplotlib.collections.LineCollection properties.
Expand All @@ -120,7 +120,7 @@ def matplotlib(self, name=None, **kwargs):
return ax

class SparselyProfileMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
""" Plotting method for SparselyBin of Average
name : title of the plot.
kwargs : matplotlib.collections.LineCollection properties.
Expand Down Expand Up @@ -150,7 +150,7 @@ def matplotlib(self, name=None, **kwargs):
return ax

class ProfileErrMethods(object):
def matplotlib(self, name=None, aspect=True, **kwargs):
def plotmatplotlib(self, name=None, aspect=True, **kwargs):
""" Plotting method for Bin of Deviate
name : title of the plot.
aspect :
Expand Down Expand Up @@ -189,7 +189,7 @@ def matplotlib(self, name=None, aspect=True, **kwargs):
return ax

class SparselyProfileErrMethods(object):
def matplotlib(self, name=None, aspect=True, **kwargs):
def plotmatplotlib(self, name=None, aspect=True, **kwargs):
""" Plotting method for
"""
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -235,7 +235,7 @@ def matplotlib(self, name=None, aspect=True, **kwargs):
return ax

class StackedHistogramMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
""" Plotting method for
"""
import matplotlib.pyplot as plt
Expand All @@ -247,7 +247,7 @@ def matplotlib(self, name=None, **kwargs):

for i, hist in enumerate(self.values):
color = color_cycle[i]
hist.matplotlib(color=color, label=hist.name, **kwargs)
hist.plotmatplotlib(color=color, label=hist.name, **kwargs)
color_cycle.append(color)

if name is not None:
Expand All @@ -257,7 +257,7 @@ def matplotlib(self, name=None, **kwargs):
return ax

class PartitionedHistogramMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
""" Plotting method for
"""
import matplotlib.pyplot as plt
Expand All @@ -269,7 +269,7 @@ def matplotlib(self, name=None, **kwargs):

for i, hist in enumerate(self.values):
color = color_cycle[i]
hist.matplotlib(color=color, label=hist.name, **kwargs)
hist.plotmatplotlib(color=color, label=hist.name, **kwargs)
color_cycle.append(color)

if name is not None:
Expand All @@ -279,7 +279,7 @@ def matplotlib(self, name=None, **kwargs):
return ax

class FractionedHistogramMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
""" Plotting method for
"""
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -319,7 +319,7 @@ def matplotlib(self, name=None, **kwargs):
return ax

class TwoDimensionallyHistogramMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
""" Plotting method for Bin of Bin of Count
name : title of the plot.
kwargs: matplotlib.collections.QuadMesh properties.
Expand Down Expand Up @@ -350,7 +350,7 @@ def matplotlib(self, name=None, **kwargs):


class SparselyTwoDimensionallyHistogramMethods(object):
def matplotlib(self, name=None, **kwargs):
def plotmatplotlib(self, name=None, **kwargs):
""" Plotting method for SparselyBin of SparselyBin of Count
name : title of the plot.
kwargs: matplotlib.collections.QuadMesh properties.
Expand Down
28 changes: 14 additions & 14 deletions histogrammar/plot/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ def setTH2sparse(sparse, yminBin, ymaxBin, th2):
# "Public" methods; what we want to attach to the Histogram as a mix-in.

class HistogramMethods(object):
def root(self, name, title="", binType="D"):
def plotroot(self, name, title="", binType="D"):
import ROOT
constructor = getattr(ROOT, "TH1" + binType)
th1 = constructor(name, title, len(self.values), self.low, self.high)
setTH1(self.entries, [x.entries for x in self.values], self.underflow.entries, self.overflow.entries, th1)
return th1

class SparselyHistogramMethods(object):
def root(self, name, title="", binType="D"):
def plotroot(self, name, title="", binType="D"):
import ROOT
constructor = getattr(ROOT, "TH1" + binType)
if self.minBin is None or self.maxBin is None:
Expand All @@ -87,7 +87,7 @@ def root(self, name, title="", binType="D"):
return th1

class ProfileMethods(object):
def root(self, name, title=""):
def plotroot(self, name, title=""):
import ROOT
tprofile = ROOT.TProfile(name, title, len(self.values), self.low, self.high)
tprofile.SetBinContent(0, self.underflow.entries*self.underflow.entries)
Expand All @@ -103,7 +103,7 @@ def root(self, name, title=""):
return tprofile

class SparselyProfileMethods(object):
def root(self, name, title=""):
def plotroot(self, name, title=""):
import ROOT
if self.minBin is None or self.maxBin is None:
tprofile = ROOT.TProfile(name, title, 1, self.origin, self.origin + 1.0)
Expand All @@ -124,7 +124,7 @@ def root(self, name, title=""):
return tprofile

class ProfileErrMethods(object):
def root(self, name, title=""):
def plotroot(self, name, title=""):
import ROOT
tprofile = ROOT.TProfile(name, title, len(self.values), self.low, self.high)
tprofile.SetBinContent(0, self.underflow.entries*self.underflow.entries)
Expand All @@ -140,7 +140,7 @@ def root(self, name, title=""):
return tprofile

class SparselyProfileErrMethods(object):
def root(self, name, title=""):
def plotroot(self, name, title=""):
import ROOT
if self.minBin is None or self.maxBin is None:
tprofile = ROOT.TProfile(name, title, 1, self.origin, self.origin + 1.0)
Expand All @@ -161,15 +161,15 @@ def root(self, name, title=""):
return tprofile

class StackedHistogramMethods(object):
def root(self, *names):
def plotroot(self, *names):
import ROOT
out = OrderedDict()
for n, (c, v) in zip(names, self.cuts):
if isinstance(n, (list, tuple)) and len(n) == 2:
name, title = n
else:
name, title = n, ""
out[c] = v.root(name, title)
out[c] = v.plotroot(name, title)

def Draw(self, options=""):
first = True
Expand All @@ -183,15 +183,15 @@ def Draw(self, options=""):
return out

class PartitionedHistogramMethods(object):
def root(self, *names):
def plotroot(self, *names):
import ROOT
out = OrderedDict()
for n, (c, v) in zip(names, self.cuts):
if isinstance(n, (list, tuple)) and len(n) == 2:
name, title = n
else:
name, title = n, ""
out[c] = v.root(name, title)
out[c] = v.plotroot(name, title)

def Draw(self, options=""):
first = True
Expand All @@ -205,9 +205,9 @@ def Draw(self, options=""):
return out

class FractionedHistogramMethods(object):
def root(self, numeratorName, denominatorName):
def plotroot(self, numeratorName, denominatorName):
import ROOT
denominator = self.denominator.root(denominatorName)
denominator = self.denominator.plotroot(denominatorName)
num = denominator.GetNbinsX()
low = denominator.GetBinLowEdge(1)
high = denominator.GetBinLowEdge(num) + denominator.GetBinWidth(num)
Expand All @@ -225,7 +225,7 @@ def root(self, numeratorName, denominatorName):
return ROOT.TEfficiency(numerator, denominator)

class TwoDimensionallyHistogramMethods(object):
def root(self, name, title="", binType="D"):
def plotroot(self, name, title="", binType="D"):
import ROOT
constructor = getattr(ROOT, "TH2" + binType)
sample = self.values[0]
Expand All @@ -236,7 +236,7 @@ def root(self, name, title="", binType="D"):
return th2

class SparselyTwoDimensionallyHistogramMethods(object):
def root(self, name, title="", binType="D"):
def plotroot(self, name, title="", binType="D"):
import ROOT
constructor = getattr(ROOT, "TH2" + binType)
yminBin, ymaxBin, ynum, ylow, yhigh = prepareTH2sparse(self)
Expand Down
Loading