MCPcopy Create free account
hub / github.com/python-visualization/folium / ColorLine

Class ColorLine

folium/features.py:1955–2023  ·  view source on GitHub ↗

Draw data on a map with specified colors. Parameters ---------- positions: iterable of (lat, lon) pairs The points on the line. Segments between points will be colored. colors: iterable of float Values that determine the color of a line segment. It must

Source from the content-addressed store, hash-verified

1953
1954
1955class ColorLine(FeatureGroup):
1956 """
1957 Draw data on a map with specified colors.
1958
1959 Parameters
1960 ----------
1961 positions: iterable of (lat, lon) pairs
1962 The points on the line. Segments between points will be colored.
1963 colors: iterable of float
1964 Values that determine the color of a line segment.
1965 It must have length equal to `len(positions)-1`.
1966 colormap: branca.colormap.Colormap or list or tuple
1967 The colormap to use. If a list or tuple of colors is provided,
1968 a LinearColormap will be created from it.
1969 nb_steps: int, default 12
1970 The colormap will be discretized to this number of colors.
1971 opacity: float, default 1
1972 Line opacity, scale 0-1
1973 weight: int, default 2
1974 Stroke weight in pixels
1975 **kwargs
1976 Further parameters available. See folium.map.FeatureGroup
1977
1978 Returns
1979 -------
1980 A ColorLine object that you can `add_to` a Map.
1981
1982 """
1983
1984 def __init__(
1985 self,
1986 positions: TypeLine,
1987 colors: Iterable[float],
1988 colormap: Union[ColorMap, Sequence[Any], None] = None,
1989 nb_steps: int = 12,
1990 weight: Optional[int] = None,
1991 opacity: Optional[float] = None,
1992 **kwargs: Any,
1993 ):
1994 super().__init__(**kwargs)
1995 self._name = "ColorLine"
1996 coords = validate_locations(positions)
1997
1998 if colormap is None:
1999 cm: StepColormap = LinearColormap(
2000 ["green", "yellow", "red"],
2001 vmin=min(colors),
2002 vmax=max(colors),
2003 ).to_step(nb_steps)
2004 elif isinstance(colormap, LinearColormap):
2005 cm = colormap.to_step(nb_steps)
2006 elif isinstance(colormap, list) or isinstance(colormap, tuple):
2007 cm = LinearColormap(
2008 colormap,
2009 vmin=min(colors),
2010 vmax=max(colors),
2011 ).to_step(nb_steps)
2012 elif isinstance(colormap, StepColormap):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…