Skip to content

Commit 54da444

Browse files
authored
Always Rasterize with default UxDataArray.plot() (#762)
* update default plotting method * update value error * update usage example * Update accessor.py
1 parent 0020265 commit 54da444

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

docs/examples/007-polygon-viz.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
},
101101
"source": [
102102
"## Using the `UxDataArray.plot()` Accessor\n",
103-
"For face-centered data, the default plotting method returns a Polygon plot."
103+
"For face-centered data, the default plotting method returns a rasterized polygon plot."
104104
]
105105
},
106106
{

uxarray/plot/dataarray_plot.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,25 @@
1313
import holoviews as hv
1414
from holoviews.operation.datashader import rasterize as hds_rasterize
1515

16-
from uxarray.plot.constants import N_FACE_THRESHOLD
17-
1816

1917
import numpy as np
2018

21-
2219
import uxarray.plot.utils
2320

2421

2522
def plot(uxda, **kwargs):
26-
"""Default Plotting Method for UxDataArray."""
23+
"""Default plotting method for a ``UxDataArray``."""
24+
2725
if uxda._face_centered():
28-
# default to polygon plot
29-
if uxda.uxgrid.n_face < N_FACE_THRESHOLD:
30-
# vector polygons for small datasets
31-
if "exclude_antimeridian" in kwargs:
32-
return polygons(uxda, **kwargs)
33-
else:
34-
return polygons(uxda, exclude_antimeridian=False, **kwargs)
35-
36-
else:
37-
# rasterized polygons for larger datasets
38-
return rasterize(uxda, method="polygon", **kwargs)
39-
elif uxda._node_centered():
40-
# default to point plots
41-
return points(uxda, **kwargs)
42-
elif uxda._edge_centered():
43-
# default to edge plots
44-
return points(uxda, **kwargs)
26+
return rasterize(uxda, method="polygon", **kwargs)
27+
28+
elif uxda._edge_centered() or uxda._node_centered():
29+
return rasterize(uxda, method="point", **kwargs)
4530

4631
else:
47-
raise ValueError("Data must be either node or face centered.")
32+
raise ValueError(
33+
"Plotting variables on unstructured grids requires the data variable to be mapped to either the nodes, edges, or faces."
34+
)
4835

4936

5037
def datashade(

0 commit comments

Comments
 (0)