matplotlib_radar#

Attributes#

Functions#

radar_chart(label, data[, cmap, ax, return_axis, ...])

Generate radar chart with matplotlib.

Package Contents#

matplotlib_radar.__version__ = '0.1.0'#
matplotlib_radar.radar_chart(label, data, cmap='tab10', ax=None, return_axis=False, show_grid=True, rotation=0, ticks=3, vmax=None, vmin=0, title=None, opacity=0.25)#

Generate radar chart with matplotlib.

from matplotlib_radar import radar_chart
import numpy as np

radar_chart(
    label=["A", "B", "C", "D", "E"],
    data={
        "Sample 1": np.random.rand(5),
        "Sample 2": np.random.rand(5),
        "Sample 3": np.random.rand(5),
    },
    title="Radar chart example",
)
Parameters:
  • label (List[str]) – List of labels to annotate polar axes.

  • data (Union[numpy.ndarray[numpy.number], Dict[str, numpy.ndarray[numpy.number]]]) – Data to plot as radar chart. As data type list or numpy array of numbers are supported. If plotting multiple samples, data must be a dictionary with labels as keys and data arrays as values.

  • cmap (Union[matplotlib.colors.Colormap, matplotlib.colors.ListedColormap, str, List[str], List[Tuple[float, float, float]]], optional) – Colormap for coloring plot. Provide name of colormap as string (both qualitative and sequential colormaps are valid) or pass a Colormap object. Defaults to "tab10".

  • ax (Optional[matplotlib.projections.polar.PolarAxes], optional) – Matplotlib axes. Axes are generate and returned if not provided. Defaults to None.

  • return_axis (bool, optional) – Whether to return axis of the generated plot. If false, axes are returned. Defaults to False.

  • show_grid (bool, optional) – Show grid. Defaults to True.

  • rotation (int, optional) – Rotation of polar axes. Defaults to 0.

  • ticks (Union[int, List[float], List[int]]) – Define ticks for plot. Provide number of ticks to generate or and array of numbers to tick values. Defaults to 3.

  • vmax (Optional[Union[int, float]], optional) – Axes maximal value. Defaults to None. If None, maximal value is calculated from provided data.

  • vmin (Union[int, float], optional) – Axes minimal value. Defaults to 0.

  • title (Optional[str], optional) – Title of plot. Defaults to None.

  • opacity (float, optional) – Alpha value of plot fill color. Defaults to 0.25.

Raises:
  • AssertionError – If labels are not provided.

  • AssertionError – If data array has more than 2 dimensions.

  • TypeError – If other types besides Colormap or str are passed as cmap parameter.

Returns:

Return axes if show_figure=False. Otherwise returns None.

Return type:

Union[matplotlib.projections.polar.PolarAxes, None]