|
| 1 | +""" |
| 2 | +scatter - Scatter plot. |
| 3 | +""" |
| 4 | + |
| 5 | +from pygmt.helpers import is_nonstr_iter |
| 6 | + |
| 7 | + |
| 8 | +def _parse_symbol_size(symbol, size): |
| 9 | + """ |
| 10 | + Parse the symbol and size into a style string. |
| 11 | +
|
| 12 | + >>> _parse_symbol_size("c", 0.2) |
| 13 | + 'c0.2' |
| 14 | + >>> _parse_symbol_size("c", "0.2c") |
| 15 | + 'c0.2c' |
| 16 | + >>> _parse_symbol_size("c", [0.2, 0.3]) |
| 17 | + 'c' |
| 18 | + >>> _parse_symbol_size(["c", "t"], "0.2c"]) |
| 19 | + '0.2c' |
| 20 | + >>> _parse_symbol_size(["c", "t"], [0.2, 0.3]) |
| 21 | + '' |
| 22 | + """ |
| 23 | + return "".join(f"{arg}" for arg in [symbol, size] if not is_nonstr_iter(arg)) |
| 24 | + |
| 25 | + |
| 26 | +def scatter(self, x, y, symbol, size, **kwargs): |
| 27 | + """ |
| 28 | + Plot scatter points on a map. |
| 29 | +
|
| 30 | + Parameters |
| 31 | + ---------- |
| 32 | + x, y : array-like |
| 33 | + The coordinates of the points to plot. |
| 34 | + symbol : str or sequence |
| 35 | + The symbol to use for the points. |
| 36 | + size : float or sequence |
| 37 | + The size of the points. |
| 38 | + """ |
| 39 | + kwargs = self._preprocess(**kwargs) |
| 40 | + |
| 41 | + # style is a combination of symbol and size, but only if they are string-like |
| 42 | + style = _parse_symbol_size(symbol, size) |
| 43 | + if not is_nonstr_iter(symbol): |
| 44 | + symbol = None |
| 45 | + if not is_nonstr_iter(size): |
| 46 | + size = None |
| 47 | + |
| 48 | + self.plot(x=x, y=y, style=style, symbol=symbol, size=size, **kwargs) |
0 commit comments