diff --git a/active_projects/eop/histograms.py b/active_projects/eop/histograms.py index 97ed6445..5f89a407 100644 --- a/active_projects/eop/histograms.py +++ b/active_projects/eop/histograms.py @@ -18,7 +18,11 @@ class Histogram(VMobject): "y_scale" : 1.0, "x_labels" : "auto", # widths, mids, auto, none, [...] "y_labels" : "auto", # auto, none, [...] - "x_min" : 0 + "y_label_position" : "top", # "center" + "x_min" : 0, + "bar_stroke_width" : 5, + "outline_stroke_width" : 0, + "stroke_color" : WHITE } def __init__(self, x_values, y_values, mode = "widths", **kwargs): @@ -119,6 +123,8 @@ class Histogram(VMobject): bar = Rectangle( width = self.widths_scaled[i], height = self.y_values_scaled[i], + stroke_width = self.bar_stroke_width, + stroke_color = self.stroke_color, ) t = float(x - self.x_min)/(self.x_max - self.x_min) bar_color = interpolate_color( @@ -127,7 +133,6 @@ class Histogram(VMobject): t ) bar.set_fill(color = bar_color, opacity = 1) - bar.set_stroke(width = 0) bar.next_to(previous_bar,RIGHT,buff = 0, aligned_edge = DOWN) self.bars.add(bar) @@ -137,7 +142,12 @@ class Histogram(VMobject): self.x_labels_group.add(x_label) y_label = TextMobject(self.y_labels[i]) - y_label.next_to(bar, UP) + if self.y_label_position == "top": + y_label.next_to(bar, UP) + elif self.y_label_position == "center": + y_label.move_to(bar) + else: + raise Exception("y_label_position must be top or center") self.y_labels_group.add(y_label) if i == 0: @@ -155,8 +165,9 @@ class Histogram(VMobject): # lower left outline_points.append(outline_points[0]) - self.outline = Polygon(*outline_points) - self.outline.set_stroke(color = WHITE) + self.outline = Polygon(*outline_points, + stroke_width = self.outline_stroke_width, + stroke_color = self.stroke_color) self.add(self.bars, self.x_labels_group, self.y_labels_group, self.outline) print self.submobjects