コード例 #1
0
def test_Quad():
    glyph = Quad()
    assert glyph.left == "left"
    assert glyph.right == "right"
    assert glyph.bottom == "bottom"
    assert glyph.top == "top"
    yield check_fill, glyph
    yield check_line, glyph
    yield check_props, glyph, ["left", "right", "bottom", "top"], FILL, LINE
コード例 #2
0
ファイル: test_glyphs.py プロジェクト: JosephCottam/bokeh
class TestQuad(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import Quad

        self.test_quad = Quad()

    def test_expected_properties(self):
        expected_properties = set(["left", "right", "bottom", "top"])
        actual_properties = get_prop_set(type(self.test_quad))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_quad.left, "left")
        self.assertEqual(self.test_quad.right, "right")
        self.assertEqual(self.test_quad.bottom, "bottom")
        self.assertEqual(self.test_quad.top, "top")
        self.assertEqual(self.test_quad.__view_model__, "quad")

    def test_to_glyphspec(self):
        expected = dict(GENERIC_FILL_DICT)
        expected.update(GENERIC_LINE_DICT)
        expected["type"] = "quad"
        expected.update(
            {
                "left": {"units": "data", "field": "left"},
                "right": {"units": "data", "field": "right"},
                "top": {"units": "data", "field": "top"},
                "bottom": {"units": "data", "field": "bottom"},
            }
        )
        self.assertEqual(self.test_quad.to_glyphspec(), expected)
        self.test_quad.left = 50
        self.test_quad.right = 51
        self.test_quad.bottom = 52
        self.test_quad.top = 53
        expected.update(
            {
                "left": {"units": "data", "value": 50},
                "right": {"units": "data", "value": 51},
                "bottom": {"units": "data", "value": 52},
                "top": {"units": "data", "value": 53},
            }
        )
        self.assertEqual(self.test_quad.to_glyphspec(), expected)
コード例 #3
0
    def pyramid_plot(self):
        from bokeh.objects import (Plot, DataRange1d, LinearAxis, Grid, Legend,
                                   SingleIntervalTicker)
        from bokeh.glyphs import Quad

        xdr = DataRange1d(sources=[
            self.source_pyramid.columns("male"),
            self.source_pyramid.columns("female")
        ])
        ydr = DataRange1d(sources=[self.source_pyramid.columns("groups")])

        self.plot = Plot(title=None,
                         x_range=xdr,
                         y_range=ydr,
                         plot_width=600,
                         plot_height=600)

        xaxis = LinearAxis()
        self.plot.add_layout(xaxis, 'below')
        yaxis = LinearAxis(ticker=SingleIntervalTicker(interval=5))
        self.plot.add_layout(yaxis, 'left')

        self.plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
        self.plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

        male_quad = Quad(left="male",
                         right=0,
                         bottom="groups",
                         top="shifted",
                         fill_color="#3B8686")
        male_quad_glyph = self.plot.add_glyph(self.source_pyramid, male_quad)

        female_quad = Quad(left=0,
                           right="female",
                           bottom="groups",
                           top="shifted",
                           fill_color="#CFF09E")
        female_quad_glyph = self.plot.add_glyph(self.source_pyramid,
                                                female_quad)

        self.plot.add_layout(
            Legend(legends=dict(Male=[male_quad_glyph],
                                Female=[female_quad_glyph])))
コード例 #4
0
ファイル: test_glyphs.py プロジェクト: FLOKSociety/bokeh
class TestQuad(unittest.TestCase):

    def setUp(self):
        from bokeh.glyphs import Quad
        self.test_quad = Quad()

    def test_expected_properties(self):
        expected_properties = set(['left', 'right', 'bottom', 'top'])
        actual_properties = get_prop_set(type(self.test_quad))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_quad.left, 'left')
        self.assertEqual(self.test_quad.right, 'right')
        self.assertEqual(self.test_quad.bottom, 'bottom')
        self.assertEqual(self.test_quad.top, 'top')
        self.assertEqual(self.test_quad.__view_model__, 'quad')

    def test_to_glyphspec(self):
        expected = dict(GENERIC_FILL_DICT)
        expected.update(GENERIC_LINE_DICT)
        expected['type'] = 'quad'
        expected.update({
            'left':   {'units': 'data', 'field': 'left'},
            'right':  {'units': 'data', 'field': 'right'},
            'top':    {'units': 'data', 'field': 'top'},
            'bottom': {'units': 'data', 'field': 'bottom'},
        })
        self.assertEqual(self.test_quad.to_glyphspec(), expected)
        self.test_quad.left = 50
        self.test_quad.right = 51
        self.test_quad.bottom = 52
        self.test_quad.top = 53
        expected.update({
            'left':   {'units': 'data', 'value': 50},
            'right':  {'units': 'data', 'value': 51},
            'bottom': {'units': 'data', 'value': 52},
            'top':    {'units': 'data', 'value': 53},
        })
        self.assertEqual(self.test_quad.to_glyphspec(), expected)
コード例 #5
0
def pyramid():
    xdr = DataRange1d(sources=[
        source_pyramid.columns("male"),
        source_pyramid.columns("female")
    ])
    ydr = DataRange1d(sources=[source_pyramid.columns("groups")])

    plot = Plot(title=None,
                x_range=xdr,
                y_range=ydr,
                plot_width=600,
                plot_height=600)

    xaxis = LinearAxis()
    plot.add_layout(xaxis, 'below')
    yaxis = LinearAxis(ticker=SingleIntervalTicker(interval=5))
    plot.add_layout(yaxis, 'left')

    plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
    plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

    male_quad = Quad(left="male",
                     right=0,
                     bottom="groups",
                     top="shifted",
                     fill_color="#3B8686")
    male_quad_glyph = plot.add_glyph(source_pyramid, male_quad)

    female_quad = Quad(left=0,
                       right="female",
                       bottom="groups",
                       top="shifted",
                       fill_color="#CFF09E")
    female_quad_glyph = plot.add_glyph(source_pyramid, female_quad)

    plot.add_layout(
        Legend(
            legends=dict(Male=[male_quad_glyph], Female=[female_quad_glyph])))

    return plot
コード例 #6
0
ファイル: test_glyphs.py プロジェクト: JaakkoTulkki/bokeh
class TestQuad(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import Quad
        self.test_quad = Quad()

    def test_expected_properties(self):
        expected_properties = set(['left','right','bottom','top'])
        actual_properties = get_prop_set(type(self.test_quad))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_quad.left,'left')
        self.assertEqual(self.test_quad.right,'right')
        self.assertEqual(self.test_quad.bottom,'bottom')
        self.assertEqual(self.test_quad.top,'top')
        self.assertEqual(self.test_quad.__view_model__,'quad')

    def test_to_glyphspec(self):
        self.assertEqual(self.test_quad.to_glyphspec(), {'line_color': {'value': 'black'}, 'right': {'units': 'data', 'field': 'right'}, 'fill_color': {'value': 'gray'}, 'bottom': {'units': 'data', 'field': 'bottom'}, 'top': {'units': 'data', 'field': 'top'}, 'type': 'quad', 'left': {'units': 'data', 'field': 'left'}})
        self.test_quad.left = 50
        self.test_quad.right = 51
        self.test_quad.bottom = 52
        self.test_quad.top = 53
        self.assertEqual(self.test_quad.to_glyphspec(), {'line_color': {'value': 'black'}, 'right': {'units': 'data', 'value': 51}, 'fill_color': {'value': 'gray'}, 'bottom': {'units': 'data', 'value': 52}, 'top': {'units': 'data', 'value': 53}, 'type': 'quad', 'left': {'units': 'data', 'value': 50}})
コード例 #7
0
def pyramid():
    xdr = DataRange1d(sources=[source_pyramid.columns("male"), source_pyramid.columns("female")])
    ydr = DataRange1d(sources=[source_pyramid.columns("groups")])

    plot = Plot(title=None, data_sources=[source_pyramid], x_range=xdr, y_range=ydr, plot_width=600, plot_height=600)

    xaxis = LinearAxis(plot=plot, dimension=0)
    yaxis = LinearAxis(plot=plot, dimension=1, ticker=SingleIntervalTicker(interval=5))

    xgrid = Grid(plot=plot, dimension=0, axis=xaxis)
    ygrid = Grid(plot=plot, dimension=1, axis=yaxis)

    male_quad = Quad(left="male", right=0, bottom="groups", top="shifted", fill_color="blue")
    male_quad_glyph = Glyph(data_source=source_pyramid, xdata_range=xdr, ydata_range=ydr, glyph=male_quad)
    plot.renderers.append(male_quad_glyph)

    female_quad = Quad(left=0, right="female", bottom="groups", top="shifted", fill_color="violet")
    female_quad_glyph = Glyph(data_source=source_pyramid, xdata_range=xdr, ydata_range=ydr, glyph=female_quad)
    plot.renderers.append(female_quad_glyph)

    legend = Legend(plot=plot, legends=dict(Male=[male_quad_glyph], Female=[female_quad_glyph]))
    plot.renderers.append(legend)

    return plot
コード例 #8
0
ファイル: test_glyphs.py プロジェクト: FLOKSociety/bokeh
 def setUp(self):
     from bokeh.glyphs import Quad
     self.test_quad = Quad()
コード例 #9
0
         line_color="#D95F02",
         line_width=2)),
 ("line", Line(x="x", y="y", line_color="#F46D43")),
 ("multi_line",
  MultiLine(xs="xs", ys="ys", line_color="#8073AC", line_width=2)),
 ("oval",
  Oval(x="x",
       y="y",
       width=screen(15),
       height=screen(25),
       angle=-0.7,
       fill_color="#1D91C0")),
 ("patch", Patch(x="x", y="y", fill_color="#A6CEE3")),
 ("patches", Patches(xs="xs", ys="ys", fill_color="#FB9A99")),
 ("quad",
  Quad(left="x", right="xm01", top="y", bottom="ym01",
       fill_color="#B3DE69")),
 ("quadratic",
  Quadratic(x0="x",
            y0="y",
            x1="xp02",
            y1="y",
            cx="xp01",
            cy="yp01",
            line_color="#4DAF4A",
            line_width=3)),
 ("ray",
  Ray(x="x",
      y="y",
      length=45,
      angle=-0.7,
      line_color="#FB8072",
コード例 #10
0
 def setUp(self):
     from bokeh.glyphs import Quad
     self.test_quad = Quad()
コード例 #11
0
class TestQuad(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import Quad
        self.test_quad = Quad()

    def test_expected_properties(self):
        expected_properties = set(['left', 'right', 'bottom', 'top'])
        actual_properties = get_prop_set(type(self.test_quad))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_quad.left, 'left')
        self.assertEqual(self.test_quad.right, 'right')
        self.assertEqual(self.test_quad.bottom, 'bottom')
        self.assertEqual(self.test_quad.top, 'top')
        self.assertEqual(self.test_quad.__view_model__, 'quad')

    def test_to_glyphspec(self):
        expected = dict(GENERIC_FILL_DICT)
        expected.update(GENERIC_LINE_DICT)
        expected['type'] = 'quad'
        expected.update({
            'left': {
                'units': 'data',
                'field': 'left'
            },
            'right': {
                'units': 'data',
                'field': 'right'
            },
            'top': {
                'units': 'data',
                'field': 'top'
            },
            'bottom': {
                'units': 'data',
                'field': 'bottom'
            },
        })
        self.assertEqual(self.test_quad.to_glyphspec(), expected)
        self.test_quad.left = 50
        self.test_quad.right = 51
        self.test_quad.bottom = 52
        self.test_quad.top = 53
        expected.update({
            'left': {
                'units': 'data',
                'value': 50
            },
            'right': {
                'units': 'data',
                'value': 51
            },
            'bottom': {
                'units': 'data',
                'value': 52
            },
            'top': {
                'units': 'data',
                'value': 53
            },
        })
        self.assertEqual(self.test_quad.to_glyphspec(), expected)