Visualization
This module contains functions for visualization.
awpy.visualization.plot
Functions for plotting player positions and nades.
Typical usage example:
from awpy.visualization.plot import plot_round plot_round(“best_round_ever.gif”, d[“gameRounds”][7][“frames”], map_name=d[“mapName”], map_type=”simpleradar”, dark=False)
https://github.com/pnxenopoulos/awpy/blob/main/examples/02_Basic_CSGO_Visualization.ipynb
- awpy.visualization.plot.plot_map(map_name: str = 'de_dust2', map_type: str = 'original', dark: bool = False) tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes] [source]
Plots a blank map.
- Parameters:
map_name (string, optional) – Map to search. Defaults to “de_dust2”
map_type (string, optional) – “original” or “simpleradar”. Defaults to “original”
dark (bool, optional) – Only for use with map_type=”simpleradar”. Indicates if you want to use the SimpleRadar dark map type Defaults to False
- Returns:
matplotlib fig and ax
- awpy.visualization.plot.plot_nades(rounds: list[awpy.types.GameRound], nades: list[str] | None = None, side: str = 'CT', map_name: str = 'de_ancient', map_type: str = 'original', dark: bool = False) tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes] [source]
Plots grenade trajectories.
- Parameters:
rounds (list) – List of round objects from a parsed demo
nades (list, optional) – List of grenade types to plot Defaults to []
side (string, optional) – Specify side to plot grenades. Either “CT” or “T”. Defaults to “CT”
map_name (string, optional) – Map to search. Defaults to “de_ancient”
map_type (string, optional) – “original” or “simpleradar”. Defaults to “original”
dark (bool, optional) – Only for use with map_type=”simpleradar”. Indicates if you want to use the SimpleRadar dark map type. Defaults to False
- Returns:
matplotlib fig and ax
- awpy.visualization.plot.plot_positions(positions: list[tuple[float, float]] | None = None, colors: list[str] | None = None, markers: list[str] | None = None, alphas: list[float] | None = None, sizes: list[float] | None = None, map_name: str = 'de_ancient', map_type: str = 'original', dark: bool = False, apply_transformation: bool = False) tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes] [source]
Plots player positions
- Parameters:
positions (list, optional) – List of lists of length 2 ([[x,y], …]) Defaults to []
colors (list, optional) – List of colors for each player Defaults to []
markers (list, optional) – List of marker types for each player Defaults to []
alphas (list, optional) – List of alpha values for each player Defaults to [1.0] * len(positions)
sizes (list, optional) – List of marker sizes for each player Defaults to [mpl.rcParams[“lines.markersize”] ** 2] * len(positions)
map_name (string, optional) – Map to search. Defaults to “de_ancient”
map_type (string, optional) – “original” or “simpleradar”. Defaults to “original”
dark (bool, optional) – Only for use with map_type=”simpleradar”. Indicates if you want to use the SimpleRadar dark map type Defaults to False
apply_transformation (bool, optional) – Indicates if you need to also use position_transform() for the X/Y coordinates Defaults to False
- Returns:
matplotlib fig and ax
- awpy.visualization.plot.plot_round(filename: str, frames: list[awpy.types.GameFrame], map_name: str = 'de_ancient', map_type: str = 'original', dark: bool = False, fps: int = 10) Literal[True] [source]
Plots a round and saves as a .gif. CTs are blue, Ts are orange, and the bomb is an octagon. Only use untransformed coordinates.
- Parameters:
filename (string) – Filename to save the gif
frames (list) – List of frames from a parsed demo
map_name (string, optional) – Map to search. Defaults to “de_ancient”
map_type (string, optional) – “original” or “simpleradar”. Defaults to “original
dark (bool, optional) – Only for use with map_type=”simpleradar”. Indicates if you want to use the SimpleRadar dark map type Defaults to False
fps (int, optional) – Number of frames per second in the gif Defaults to 10
- Returns:
True, saves .gif
- awpy.visualization.plot.position_transform(map_name: str, position: float, axis: Literal['x', 'y']) float [source]
Transforms an X or Y coordinate.
- Parameters:
map_name (string) – Map to search
position (float) – X or Y coordinate
axis (string) – Either “x” or “y” (lowercase)
- Returns:
float
- Raises:
ValueError – Raises a ValueError if axis not ‘x’ or ‘y’