Пример #1
0
    def __init__(self,
                 data,
                 line_color=None,
                 line_width=2,
                 f_tooltip=None,
                 cmap=None,
                 max_area=1e4,
                 alpha=220):
        """
        Draw the voronoi tesselation of the points from data

        :param data: data access object
        :param line_color: line color
        :param line_width: line width
        :param f_tooltip: function to generate a tooltip on mouseover
        :param cmap: color map
        :param max_area: scaling constant to determine the color of the voronoi areas
        :param alpha: color alpha
        :return:
        """
        self.data = data

        if cmap is None and line_color is None:
            raise Exception('need either cmap or line_color')

        if cmap is not None:
            cmap = colors.ColorMap(cmap, alpha=alpha, levels=10)

        self.cmap = cmap
        self.line_color = line_color
        self.line_width = line_width
        self.f_tooltip = f_tooltip
        self.max_area = max_area
Пример #2
0
    def __init__(self,
                 data,
                 line_color=None,
                 line_width=2,
                 cmap=None,
                 max_lenght=100):
        """
        Draw a delaunay triangulation of the points

        :param data: data access object
        :param line_color: line color
        :param line_width: line width
        :param cmap: color map
        :param max_lenght: scaling constant for coloring the edges
        """
        self.data = data

        if cmap is None and line_color is None:
            raise Exception('need either cmap or line_color')

        if cmap is not None:
            cmap = colors.ColorMap(cmap, alpha=196)

        self.cmap = cmap
        self.line_color = line_color
        self.line_width = line_width
        self.max_lenght = max_lenght
Пример #3
0
    def __init__(self,
                 data,
                 src_lat,
                 src_lon,
                 dest_lat,
                 dest_lon,
                 linewidth=1,
                 alpha=220,
                 color='hot'):
        """Create a graph drawing a line between each pair of (src_lat, src_lon) and (dest_lat, dest_lon)

        :param data: data access object
        :param src_lat: field name of source latitude
        :param src_lon: field name of source longitude
        :param dest_lat: field name of destination latitude
        :param dest_lon: field name of destination longitude
        :param linewidth: line width
        :param alpha: color alpha
        :param color: color or colormap
        """
        self.data = data
        self.src_lon = src_lon
        self.src_lat = src_lat
        self.dest_lon = dest_lon
        self.dest_lat = dest_lat

        self.linewidth = linewidth
        alpha = alpha
        self.color = color
        if type(self.color) == str:
            self.cmap = colors.ColorMap(self.color, alpha)
Пример #4
0
    def __init__(self,
                 values,
                 bw,
                 cmap='hot',
                 method='hist',
                 scaling='sqrt',
                 alpha=220,
                 cut_below=None,
                 clip_above=None,
                 binsize=1,
                 cmap_levels=10):
        """
        Kernel density estimation visualization

        :param data: data access object
        :param bw: kernel bandwidth (in screen coordinates)
        :param cmap: colormap
        :param method: if kde use KDEMultivariate from statsmodel, which provides a more accurate but much slower estimation.
            If hist, estimates density applying gaussian smoothing on a 2D histogram, which is much faster but less accurate
        :param scaling: colorscale, lin log or sqrt
        :param alpha: color alpha
        :param cut_below: densities below cut_below are not drawn
        :param clip_above: defines the max value for the colorscale
        :param binsize: size of the bins for hist estimator
        :param cmap_levels: discretize colors into cmap_levels
        """
        self.values = values
        self.bw = bw
        self.cmap = colors.ColorMap(cmap, alpha=alpha, levels=cmap_levels)
        self.method = method
        self.scaling = scaling
        self.cut_below = cut_below
        self.clip_above = clip_above
        self.binsize = binsize
Пример #5
0
    def __init__(self,
                 data,
                 cmap='hot',
                 alpha=220,
                 colorscale='sqrt',
                 binsize=16,
                 show_tooltip=False,
                 scalemin=0,
                 scalemax=None,
                 f_group=None):
        """Create a 2D histogram

        :param data: data access object
        :param cmap: colormap name
        :param alpha: color alpha
        :param colorscale: scaling [lin, log, sqrt]
        :param binsize: size of the hist bins
        :param show_tooltip: if True, will show the value of bins on mouseover
        :param scalemin: min value for displaying a bin
        :param scalemax: max value for a bin
        :param f_group: function to apply to samples in the same bin. Default is to count
        :return:
        """
        self.data = data
        self.cmap = colors.ColorMap(cmap, alpha=alpha)
        self.binsize = binsize
        self.show_tooltip = show_tooltip
        self.scalemin = scalemin
        self.scalemax = scalemax
        self.colorscale = colorscale
        self.f_group = f_group
        if self.f_group is None:
            self.f_group = lambda grp: len(grp)
Пример #6
0
    def __init__(self,
                 lon_edges,
                 lat_edges,
                 values,
                 cmap,
                 alpha=255,
                 vmin=None,
                 vmax=None,
                 levels=10,
                 colormap_scale='lin',
                 show_colorbar=True):
        """
        Values over a uniform grid
        
        :param lon_edges: longitude edges
        :param lat_edges: latitude edges
        :param values: matrix representing values on the grid 
        :param cmap: colormap name
        :param alpha: color alpha
        :param vmin: minimum value for the colormap
        :param vmax: maximum value for the colormap
        :param levels: number of levels for the colormap
        :param colormap_scale: colormap scale
        :param show_colorbar: show the colorbar in the UI
        """
        self.lon_edges = lon_edges
        self.lat_edges = lat_edges
        self.values = values
        self.cmap = colors.ColorMap(cmap, alpha=alpha, levels=levels)
        self.colormap_scale = colormap_scale
        self.show_colorbar = show_colorbar

        if vmin:
            self.vmin = vmin
        else:
            self.vmin = 0

        if vmax:
            self.vmax = vmax
        else:
            self.vmax = self.values[~np.isnan(self.values)].max()
Пример #7
0
    def __init__(self,
                 lon_edges,
                 lat_edges,
                 values,
                 cmap,
                 alpha=255,
                 vmin=None,
                 vmax=None):
        self.lon_edges = lon_edges
        self.lat_edges = lat_edges
        self.values = values
        self.cmap = colors.ColorMap(cmap, alpha=alpha)

        if vmin:
            self.vmin = vmin
        else:
            self.vmin = 0

        if vmax:
            self.vmax = vmax
        else:
            self.vmax = self.values.max()