Beispiel #1
0
    def test(self):
        info = infos.valAt(3, "Nothing")

        self.assertTrue(callable(info))
        self.assertEqual(3, info([0, 1, 2, 3]))
        self.assertEqual("three", info(["zero", "one", "two", "three"]))
        self.assertEqual("Nothing", info(None))
    def test(self):
        info = infos.valAt(3, "Nothing")

        self.assertTrue(callable(info))
        self.assertEqual(3, info([0, 1, 2, 3]))
        self.assertEqual("three", info(["zero", "one", "two", "three"]))
        self.assertEqual("Nothing", info(None))
Beispiel #3
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