def get_node_colors_by_attr(
    G: nx.MultiDiGraph,
    attr: str,
    *,
    num_bins: int | None = None,
    cmap: str = "viridis",
    start: float = 0,
    stop: float = 1,
    na_color: str = "none",
    equal_size: bool = False,
) -> pd.Series:  # type: ignore[type-arg]
    """
    Return colors based on nodes' numerical attribute values.

    Parameters
    ----------
    G
        Input graph.
    attr
        Name of a node attribute with numerical values.
    num_bins
        If None, linearly map a color to each value. Otherwise, assign values
        to this many bins then assign a color to each bin.
    cmap
        Name of the matplotlib colormap from which to choose the colors.
    start
        Where to start in the colorspace (from 0 to 1).
    stop
        Where to end in the colorspace (from 0 to 1).
    na_color
        The color to assign to nodes with missing `attr` values.
    equal_size
        Ignored if `num_bins` is None. If True, bin into equal-sized quantiles
        (requires unique bin edges). If False, bin into equal-spaced bins.

    Returns
    -------
    node_colors
        Labels are node IDs, values are colors as hex strings.
    """
    vals = pd.Series(nx.get_node_attributes(G, attr))
    return _get_colors_by_value(vals, num_bins, cmap, start, stop, na_color, equal_size)

    Return colors based on nodes' numerical attribute values.

    Parameters
    ----------
    G
        Input graph.
    attr
        Name of a node attribute with numerical values.
    num_bins
        If None, linearly map a color to each value. Otherwise, assign values
        to this many bins then assign a color to each bin.
    cmap
        Name of the matplotlib colormap from which to choose the colors.
    start
        Where to start in the colorspace (from 0 to 1).
    stop
        Where to end in the colorspace (from 0 to 1).
    na_color
        The color to assign to nodes with missing `attr` values.
    equal_size
        Ignored if `num_bins` is None. If True, bin into equal-sized quantiles
        (requires unique bin edges). If False, bin into equal-spaced bins.

    Returns
    -------
    node_colors
        Labels are node IDs, values are colors as hex strings.
    
osmnx/plot.py