def test_pan_scale(self):
        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 20, 20)),
                         [0., 0., .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (5, 5, 20, 20)),
                         [-2.5, -2.5, .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (-4, -7, 20, 20)),
                         [2., 3.5, .5, .5])
Beispiel #2
0
    def test_pan_scale(self):
        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 20, 20)),
                         [0., 0., .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (5, 5, 20, 20)),
                         [-2.5, -2.5, .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (-4, -7, 20, 20)),
                         [2., 3.5, .5, .5])
    def test_pan(self):
        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 10)),
                         [0., 0., 1., 1.])

        self.assertEqual(util.zoom_fit((10, 10), (5, 5, 10, 10)),
                         [-5., -5., 1., 1.])

        self.assertEqual(util.zoom_fit((10, 10), (-4, -7, 10, 10)),
                         [4., 7., 1., 1.])
Beispiel #4
0
    def test_pan(self):
        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 10)),
                         [0., 0., 1., 1.])

        self.assertEqual(util.zoom_fit((10, 10), (5, 5, 10, 10)),
                         [-5., -5., 1., 1.])

        self.assertEqual(util.zoom_fit((10, 10), (-4, -7, 10, 10)),
                         [4., 7., 1., 1.])
    def test_scale(self):
        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 10)),
                         [0., 0., 1., 1.])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 20, 20)),
                         [0., 0., .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 5, 5)),
                         [0., 0., 2., 2.])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 20)),
                         [0., 0., .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 20), False),
                         [0., 0., 1., .5])
Beispiel #6
0
    def test_scale(self):
        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 10)),
                         [0., 0., 1., 1.])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 20, 20)),
                         [0., 0., .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 5, 5)),
                         [0., 0., 2., 2.])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 20)),
                         [0., 0., .5, .5])

        self.assertEqual(util.zoom_fit((10, 10), (0, 0, 10, 20), False),
                         [0., 0., 1., .5])
Beispiel #7
0
def _create_plot_component():
    red = util.Color(255, 0, 0, 255)
    green = util.Color(0, 255, 0, 255)
    blue = util.Color(0, 0, 255, 255)
    purple = util.Color(125, 0, 255, 255)
    white = util.Color(255, 255, 255, 255)
    black = util.Color(0, 0, 0, 255)
    clear = util.Color(0, 0, 0, 0)

    with Timer("Loeading") as arTimer:
        #glyphs = npg.load_csv("../data/circlepoints.csv", 1, 2, 3, 4)
        #glyphs = npg.load_hdf("../data/CensusTracts.hdf5", "__data__", "LAT", "LON")
        glyphs = npg.load_hdf("../data/tweets-subset.hdf",
                              "test",
                              "longitude",
                              "latitude",
                              vc="lang_primary")

    screen = (800, 600)
    ivt = util.zoom_fit(screen, glyphs.bounds())

    with Timer("Abstract-Render") as arTimer:
        image = core.render(
            glyphs, infos.encode(["Arabic", "English", "Turkish", "Russian"]),
            npg.PointCountCategories(),
            npg.Spread(2) + categories.HDAlpha(
                [red, blue, green, purple, black], alphamin=.3, log=True),
            screen, ivt)
#      image = core.render(glyphs,
#                          infos.valAt(4,0),
#                          npg.PointCount(),
#                          npg.Spread(1) + numeric.BinarySegment(white, black, 1),
#                          screen,
#                          ivt)

# Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", image)

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.title = "Abstract Rendering"
    plot.padding = 50

    return plot
def _create_plot_component():
    red = util.Color(255,0,0,255)
    green = util.Color(0,255,0,255)
    blue = util.Color(0,0,255,255)
    purple = util.Color(125,0,255,255)
    white = util.Color(255,255,255,255)
    black = util.Color(0,0,0,255)
    clear = util.Color(0,0,0,0)
    
    with Timer("Loeading") as arTimer:   
        #glyphs = npg.load_csv("../data/circlepoints.csv", 1, 2, 3, 4)
        glyphs = npg.load_hdf("../data/CensusTracts.hdf5", "__data__", "LAT", "LON")
        #glyphs = npg.load_hdf("../data/tweets-subset.hdf", "test", 
        #                      "longitude", "latitude", vc="lang_primary")

    screen = (800,600)
    ivt = util.zoom_fit(screen,glyphs.bounds())

    with Timer("Abstract-Render") as arTimer:   
      image = core.render(glyphs, 
                          infos.encode(["Arabic","English","Turkish","Russian"]),
                          npg.PointCountCategories(),
                          npg.Spread(2) + categories.HDAlpha([red, blue, green, purple, black], alphamin=.3, log=True),
                          screen,
                          ivt)
#      image = core.render(glyphs, 
#                          infos.valAt(4,0),
#                          npg.PointCount(),
#                          npg.Spread(1) + numeric.BinarySegment(white, black, 1),
#                          screen,
#                          ivt)

    # Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", image)

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.title = "Abstract Rendering"
    plot.padding = 50
    
    return plot
Beispiel #9
0
def _create_plot_component():
    red = util.Color(255,0,0,255)
    green = util.Color(0,255,0,255)
    blue = util.Color(0,0,255,255)
    white = util.Color(255,255,255,255)
    black = util.Color(0,0,0,255)
    
    shape = glyphset.ShapeCodes.POINT
    #glyphs = glyphset.load_csv("../data/checkerboard.csv", 2, 0, 1, 3,1,1, shape)
    #glyphs = glyphset.load_csv("../data/circlepoints.csv", 1, 2, 3, 4,.1,.1, shape)
    #glyphs = glyphset.load_csv("../data/sourceforge.csv", 1, 1, 2, -1,.1,.1, shape)
    glyphs = glyphset.load_hdf("../data/CensusTracts.hdf5", "__data__", "LON", "LAT", None, .1, .1, shape)
    #glyphs = glyphset.load_hdf("../data/tweets-subset.hdf", "test", "longitude", "latitude", None, .1, .1, shape)

    screen = (800,600)
    ivt = util.zoom_fit(screen,glyphs.bounds())

    with Timer("Abstract-Render") as arTimer:   
#      image = core.render(glyphs, 
#                          infos.val(),
#                          categories.CountCategories(), 
#                          categories.HDAlpha([red, blue]),
#                          screen,
#                          ivt)
      image = core.render(glyphs, 
                          infos.valAt(4,0),
                          numeric.Count(),
                          numeric.BinarySegment(white, black, 1),
                          screen,
                          ivt)
    print("screen x image -- {0} x {1}".format(screen, image.shape))

    # Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", image)

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.title = "Abstract Rendering"
    plot.padding = 50
    
    return plot
Beispiel #10
0
def _create_plot_component():
    red = util.Color(255, 0, 0, 255)
    green = util.Color(0, 255, 0, 255)
    blue = util.Color(0, 0, 255, 255)
    purple = util.Color(125, 0, 255, 255)
    white = util.Color(255, 255, 255, 255)
    black = util.Color(0, 0, 0, 255)

    shape = glyphset.ShapeCodes.RECT
    glyphs = blzg.load_csv(
        "../data/circlepoints.csv",
        "x",
        "y",
        "series",
        schema="{r:float32, theta:float32, x:float32, y:float32, series:int32}"
    )

    screen = (800, 600)
    ivt = util.zoom_fit(screen, glyphs.bounds())

    with Timer("Abstract-Render") as arTimer:
        image = core.render(
            glyphs, infos.val(), blzg.CountCategories("int32"),
            categories.HDAlpha([red, blue, green, purple, black]), screen, ivt)
#      image = core.render(glyphs,
#                          infos.valAt(4,0),
#                          blzg.Count(),
#                          numeric.BinarySegment(white, black, 1),
#                          screen,
#                          ivt)

# Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", image)

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.title = "Abstract Rendering"
    plot.padding = 50

    return plot
def _create_plot_component():
    red = util.Color(255,0,0,255)
    green = util.Color(0,255,0,255)
    blue = util.Color(0,0,255,255)
    purple = util.Color(125,0,255,255)
    white = util.Color(255,255,255,255)
    black = util.Color(0,0,0,255)
    
    shape = glyphset.ShapeCodes.RECT
    glyphs = blzg.load_csv("../data/circlepoints.csv", "x", "y", "series", 
                            schema="{r:float32, theta:float32, x:float32, y:float32, series:int32}")

    screen = (800,600)
    ivt = util.zoom_fit(screen,glyphs.bounds())

    with Timer("Abstract-Render") as arTimer:   
      image = core.render(glyphs, 
                          infos.val(),
                          blzg.CountCategories("int32"),
                          categories.HDAlpha([red, blue, green, purple, black]),
                          screen,
                          ivt)
#      image = core.render(glyphs, 
#                          infos.valAt(4,0),
#                          blzg.Count(), 
#                          numeric.BinarySegment(white, black, 1),
#                          screen,
#                          ivt)

    # Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", image)

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.title = "Abstract Rendering"
    plot.padding = 50
    
    return plot