doc_utils

gridkit.doc_utils.generate_2d_scatter_doughnut(num_points: float, radius: float) ndarray[source]

Generate a 2d doughnut shape of points distributed using gaussian noise.

Parameters:
  • num_points (float) – The total number of points that make up the doughnut shape.

  • radius (float) – The radius of the circle around which the points are scattered

Returns:

The points that make up the doughnut shape

Return type:

numpy.ndarray

gridkit.doc_utils.plot_polygons(geoms: List[Polygon], colors: ndarray | str | None = None, cmap: str = 'viridis', fill: bool = True, filled: bool | None = None, ax=None, add_colorbar=False, **kwargs)[source]

Plot polygons on a map and color them based on the supplied values.

Warning

This function is a workaround to have matplotlib plot arbitrary shapes. It is not performant and thus not suitable for large amounts of data. Moreover, sometimes the shapes don’t seem to align well in the corners. This is a matplotlib visualization issue, likely related to the resolution of the figure. The jagged corners tend to disappear when zooming in closely.

Parameters:
  • geoms (List[shapely.Polygon]) – A list of shapely polygons to draw

  • colors (Union[numpy.ndarray, str]) – If a string is supplied, the string is assumed to be the name of a matplotlib color, e.g. ‘green’. If colors is a numpy array or a list, these values will be used to color the supplied geoms according the the supplied cmap. If None, the all polygons will be black.

  • cmap (str) – The matplitlib complient colormap name to use Will be ignored if the ‘values’ argument not is supplied.

  • fill (bool) – Whether only the outline of the polygon should be drawn (False) or the polygon should be filled (True). If True, the ‘edgecolor’ (outline of each cell) will also be colored. If both a fill color and a small cell outline are desired, supply the keyword argument edgecolors=None alongside colors. If both a fill color and a different cell outline color are desired, supply a custom array for edgecolor alongside colors.

  • ax (matplotlib.axes.Axes (optional)) – The matplotlib axis object to plot on. If an axis object is supplied, the plot will be edited in-place. Default: matplotlib.pyplot

  • **kwargs – Keyword arguments passed to matplotlib’s PatchCollection, see: https://matplotlib.org/stable/api/collections_api.html#matplotlib.collections.Collection

Return type:

None