|
2 | 2 | plot - Plot in two dimensions. |
3 | 3 | """ |
4 | 4 |
|
5 | | -from pathlib import Path |
6 | | - |
7 | 5 | from pygmt.clib import Session |
8 | 6 | from pygmt.exceptions import GMTInvalidInput |
9 | 7 | from pygmt.helpers import ( |
|
14 | 12 | kwargs_to_strings, |
15 | 13 | use_alias, |
16 | 14 | ) |
17 | | -from pygmt.src.which import which |
| 15 | +from pygmt.src._common import _data_geometry_is_point |
18 | 16 |
|
19 | 17 |
|
20 | 18 | @fmt_docstring |
|
50 | 48 | w="wrap", |
51 | 49 | ) |
52 | 50 | @kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence") |
53 | | -def plot( # noqa: PLR0912 |
54 | | - self, data=None, x=None, y=None, size=None, direction=None, **kwargs |
55 | | -): |
| 51 | +def plot(self, data=None, x=None, y=None, size=None, direction=None, **kwargs): |
56 | 52 | r""" |
57 | 53 | Plot lines, polygons, and symbols in 2-D. |
58 | 54 |
|
@@ -242,17 +238,8 @@ def plot( # noqa: PLR0912 |
242 | 238 | raise GMTInvalidInput(f"'{name}' can't be 1-D array if 'data' is used.") |
243 | 239 |
|
244 | 240 | # Set the default style if data has a geometry of Point or MultiPoint |
245 | | - if kwargs.get("S") is None: |
246 | | - if kind == "geojson" and data.geom_type.isin(["Point", "MultiPoint"]).all(): |
247 | | - kwargs["S"] = "s0.2c" |
248 | | - elif kind == "file" and str(data).endswith(".gmt"): # OGR_GMT file |
249 | | - try: |
250 | | - with Path(which(data)).open(encoding="utf-8") as file: |
251 | | - line = file.readline() |
252 | | - if "@GMULTIPOINT" in line or "@GPOINT" in line: |
253 | | - kwargs["S"] = "s0.2c" |
254 | | - except FileNotFoundError: |
255 | | - pass |
| 241 | + if kwargs.get("S") is None and _data_geometry_is_point(data, kind): |
| 242 | + kwargs["S"] = "s0.2c" |
256 | 243 |
|
257 | 244 | with Session() as lib: |
258 | 245 | with lib.virtualfile_in( |
|
0 commit comments