Skip to content

Commit ea7f9a5

Browse files
authored
Merge pull request #13 from histogrammar/1.0.x
1.0.4
2 parents cbe1904 + e134654 commit ea7f9a5

12 files changed

Lines changed: 285 additions & 57 deletions

File tree

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
# built documents.
4848
#
4949
# The short X.Y version.
50-
version = "1.0.3"
50+
version = "1.0.4"
5151
# The full version, including alpha/beta/rc tags.
52-
release = "1.0.3"
52+
release = "1.0.4"
5353

5454
# The language for content autogenerated by Sphinx. Refer to documentation
5555
# for a list of supported languages.

histogrammar/defs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def specialize(self):
9797
except (ImportError, AttributeError):
9898
pass
9999
self.fill = FillMethod(self, self.fill)
100+
self.plot = PlotMethod(self, self.plot)
100101
return self
101102

102103
@staticmethod
@@ -179,14 +180,20 @@ def fill(self, datum, weight=1.0):
179180
"""
180181
raise NotImplementedError
181182

183+
def plot(self, httpServer=None, **parameters):
184+
"""Generate a VEGA visualization and serve it via HTTP."""
185+
raise NotImplementedError
186+
182187
def __getstate__(self):
183188
state = dict(self.__dict__)
184189
del state["fill"]
190+
del state["plot"]
185191
return state
186192

187193
def __setstate__(self, dict):
188194
self.__dict__ = dict
189195
self.fill = FillMethod(self, self.fill)
196+
self.plot = PlotMethod(self, self.plot)
190197

191198
def copy(self):
192199
"""Copy this container, making a clone with no reference to the original. """

histogrammar/plot/bokeh.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import math
2121

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

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

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

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

115115

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

119119
#glyphs
120120
from bokeh.models.glyphs import Rect, Segment, Line, Patches, Arc
@@ -166,7 +166,7 @@ class SparselyProfileMethods(object):
166166
pass
167167

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

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

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

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

250250
return stackedGlyphs
251251

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def set2Dsparse(sparse, yminBin, ymaxBin, grid):
4141
return grid
4242

4343
class HistogramMethods(object):
44-
def matplotlib(self, name=None, **kwargs):
44+
def plotmatplotlib(self, name=None, **kwargs):
4545
"""
4646
name : title of the plot.
4747
kwargs : `matplotlib.patches.Rectangle` properties.
@@ -68,7 +68,7 @@ def matplotlib(self, name=None, **kwargs):
6868
return ax
6969

7070
class SparselyHistogramMethods(object):
71-
def matplotlib(self, name=None, **kwargs):
71+
def plotmatplotlib(self, name=None, **kwargs):
7272
"""
7373
name : title of the plot.
7474
kwargs : `matplotlib.patches.Rectangle` properties.
@@ -95,7 +95,7 @@ def matplotlib(self, name=None, **kwargs):
9595
return ax
9696

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

122122
class SparselyProfileMethods(object):
123-
def matplotlib(self, name=None, **kwargs):
123+
def plotmatplotlib(self, name=None, **kwargs):
124124
""" Plotting method for SparselyBin of Average
125125
name : title of the plot.
126126
kwargs : matplotlib.collections.LineCollection properties.
@@ -150,7 +150,7 @@ def matplotlib(self, name=None, **kwargs):
150150
return ax
151151

152152
class ProfileErrMethods(object):
153-
def matplotlib(self, name=None, aspect=True, **kwargs):
153+
def plotmatplotlib(self, name=None, aspect=True, **kwargs):
154154
""" Plotting method for Bin of Deviate
155155
name : title of the plot.
156156
aspect :
@@ -189,7 +189,7 @@ def matplotlib(self, name=None, aspect=True, **kwargs):
189189
return ax
190190

191191
class SparselyProfileErrMethods(object):
192-
def matplotlib(self, name=None, aspect=True, **kwargs):
192+
def plotmatplotlib(self, name=None, aspect=True, **kwargs):
193193
""" Plotting method for
194194
"""
195195
import matplotlib.pyplot as plt
@@ -235,7 +235,7 @@ def matplotlib(self, name=None, aspect=True, **kwargs):
235235
return ax
236236

237237
class StackedHistogramMethods(object):
238-
def matplotlib(self, name=None, **kwargs):
238+
def plotmatplotlib(self, name=None, **kwargs):
239239
""" Plotting method for
240240
"""
241241
import matplotlib.pyplot as plt
@@ -247,7 +247,7 @@ def matplotlib(self, name=None, **kwargs):
247247

248248
for i, hist in enumerate(self.values):
249249
color = color_cycle[i]
250-
hist.matplotlib(color=color, label=hist.name, **kwargs)
250+
hist.plotmatplotlib(color=color, label=hist.name, **kwargs)
251251
color_cycle.append(color)
252252

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

259259
class PartitionedHistogramMethods(object):
260-
def matplotlib(self, name=None, **kwargs):
260+
def plotmatplotlib(self, name=None, **kwargs):
261261
""" Plotting method for
262262
"""
263263
import matplotlib.pyplot as plt
@@ -269,7 +269,7 @@ def matplotlib(self, name=None, **kwargs):
269269

270270
for i, hist in enumerate(self.values):
271271
color = color_cycle[i]
272-
hist.matplotlib(color=color, label=hist.name, **kwargs)
272+
hist.plotmatplotlib(color=color, label=hist.name, **kwargs)
273273
color_cycle.append(color)
274274

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

281281
class FractionedHistogramMethods(object):
282-
def matplotlib(self, name=None, **kwargs):
282+
def plotmatplotlib(self, name=None, **kwargs):
283283
""" Plotting method for
284284
"""
285285
import matplotlib.pyplot as plt
@@ -319,7 +319,7 @@ def matplotlib(self, name=None, **kwargs):
319319
return ax
320320

321321
class TwoDimensionallyHistogramMethods(object):
322-
def matplotlib(self, name=None, **kwargs):
322+
def plotmatplotlib(self, name=None, **kwargs):
323323
""" Plotting method for Bin of Bin of Count
324324
name : title of the plot.
325325
kwargs: matplotlib.collections.QuadMesh properties.
@@ -350,7 +350,7 @@ def matplotlib(self, name=None, **kwargs):
350350

351351

352352
class SparselyTwoDimensionallyHistogramMethods(object):
353-
def matplotlib(self, name=None, **kwargs):
353+
def plotmatplotlib(self, name=None, **kwargs):
354354
""" Plotting method for SparselyBin of SparselyBin of Count
355355
name : title of the plot.
356356
kwargs: matplotlib.collections.QuadMesh properties.

histogrammar/plot/root.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ def setTH2sparse(sparse, yminBin, ymaxBin, th2):
6767
# "Public" methods; what we want to attach to the Histogram as a mix-in.
6868

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

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

8989
class ProfileMethods(object):
90-
def root(self, name, title=""):
90+
def plotroot(self, name, title=""):
9191
import ROOT
9292
tprofile = ROOT.TProfile(name, title, len(self.values), self.low, self.high)
9393
tprofile.SetBinContent(0, self.underflow.entries*self.underflow.entries)
@@ -103,7 +103,7 @@ def root(self, name, title=""):
103103
return tprofile
104104

105105
class SparselyProfileMethods(object):
106-
def root(self, name, title=""):
106+
def plotroot(self, name, title=""):
107107
import ROOT
108108
if self.minBin is None or self.maxBin is None:
109109
tprofile = ROOT.TProfile(name, title, 1, self.origin, self.origin + 1.0)
@@ -124,7 +124,7 @@ def root(self, name, title=""):
124124
return tprofile
125125

126126
class ProfileErrMethods(object):
127-
def root(self, name, title=""):
127+
def plotroot(self, name, title=""):
128128
import ROOT
129129
tprofile = ROOT.TProfile(name, title, len(self.values), self.low, self.high)
130130
tprofile.SetBinContent(0, self.underflow.entries*self.underflow.entries)
@@ -140,7 +140,7 @@ def root(self, name, title=""):
140140
return tprofile
141141

142142
class SparselyProfileErrMethods(object):
143-
def root(self, name, title=""):
143+
def plotroot(self, name, title=""):
144144
import ROOT
145145
if self.minBin is None or self.maxBin is None:
146146
tprofile = ROOT.TProfile(name, title, 1, self.origin, self.origin + 1.0)
@@ -161,15 +161,15 @@ def root(self, name, title=""):
161161
return tprofile
162162

163163
class StackedHistogramMethods(object):
164-
def root(self, *names):
164+
def plotroot(self, *names):
165165
import ROOT
166166
out = OrderedDict()
167167
for n, (c, v) in zip(names, self.cuts):
168168
if isinstance(n, (list, tuple)) and len(n) == 2:
169169
name, title = n
170170
else:
171171
name, title = n, ""
172-
out[c] = v.root(name, title)
172+
out[c] = v.plotroot(name, title)
173173

174174
def Draw(self, options=""):
175175
first = True
@@ -183,15 +183,15 @@ def Draw(self, options=""):
183183
return out
184184

185185
class PartitionedHistogramMethods(object):
186-
def root(self, *names):
186+
def plotroot(self, *names):
187187
import ROOT
188188
out = OrderedDict()
189189
for n, (c, v) in zip(names, self.cuts):
190190
if isinstance(n, (list, tuple)) and len(n) == 2:
191191
name, title = n
192192
else:
193193
name, title = n, ""
194-
out[c] = v.root(name, title)
194+
out[c] = v.plotroot(name, title)
195195

196196
def Draw(self, options=""):
197197
first = True
@@ -205,9 +205,9 @@ def Draw(self, options=""):
205205
return out
206206

207207
class FractionedHistogramMethods(object):
208-
def root(self, numeratorName, denominatorName):
208+
def plotroot(self, numeratorName, denominatorName):
209209
import ROOT
210-
denominator = self.denominator.root(denominatorName)
210+
denominator = self.denominator.plotroot(denominatorName)
211211
num = denominator.GetNbinsX()
212212
low = denominator.GetBinLowEdge(1)
213213
high = denominator.GetBinLowEdge(num) + denominator.GetBinWidth(num)
@@ -225,7 +225,7 @@ def root(self, numeratorName, denominatorName):
225225
return ROOT.TEfficiency(numerator, denominator)
226226

227227
class TwoDimensionallyHistogramMethods(object):
228-
def root(self, name, title="", binType="D"):
228+
def plotroot(self, name, title="", binType="D"):
229229
import ROOT
230230
constructor = getattr(ROOT, "TH2" + binType)
231231
sample = self.values[0]
@@ -236,7 +236,7 @@ def root(self, name, title="", binType="D"):
236236
return th2
237237

238238
class SparselyTwoDimensionallyHistogramMethods(object):
239-
def root(self, name, title="", binType="D"):
239+
def plotroot(self, name, title="", binType="D"):
240240
import ROOT
241241
constructor = getattr(ROOT, "TH2" + binType)
242242
yminBin, ymaxBin, ynum, ylow, yhigh = prepareTH2sparse(self)

0 commit comments

Comments
 (0)