Repository: yt-project/yt

Issue:
BUG: to_pw ignores geometry specific rules ?
### Bug report

**Bug summary**
In spherical geometry (and probably other non-cartesian geometries too), creating a plot via `ds.slice(...).to_pw` produces inconsistent results as compared by the supposedly equivalent plot done with `yt.SlicePlot`

**Code for reproduction**


```python
import numpy as np
import yt
from yt.testing import fake_amr_ds

ds = fake_amr_ds(geometry="spherical")
field = ("stream", "Density")

yt.SlicePlot(ds, "phi", field).save("/tmp/method1.png")

slc = ds.slice("phi", np.pi)
plot = slc.to_pw(field)
plot.save("/tmp/method2.png")
```

**Actual outcome**

![method1](https://user-images.githubusercontent.com/14075922/160404012-b96493e0-74fd-4192-bd23-76a53a4522a3.png)
![method2](https://user-images.githubusercontent.com/14075922/160404018-aa52c9c1-e9fb-438a-baac-3c3793347811.png)

Note how the horizontal axis labels are incorrect in the second case
This was originally discovered and reported by @vdbma


Discussion:
Is this because it calls `_setup_plots`?
No, I think it's because some of the input sanitizing is only done in plot classes. More specifically, I'm thinking of this

https://github.com/yt-project/yt/blob/6061a1ac6d659cf656802f90b426caa8eb69f072/yt/visualization/plot_window.py#L1950-L1958


Resolving patch:
diff --git a/yt/data_objects/selection_objects/data_selection_objects.py b/yt/data_objects/selection_objects/data_selection_objects.py
--- a/yt/data_objects/selection_objects/data_selection_objects.py
+++ b/yt/data_objects/selection_objects/data_selection_objects.py
@@ -536,6 +536,7 @@ def _get_pw(self, fields, center, width, origin, plot_type):
             origin=origin,
             frb_generator=frb,
             plot_type=plot_type,
+            geometry=self.ds.geometry,
         )
         pw._setup_plots()
         return pw
diff --git a/yt/visualization/particle_plots.py b/yt/visualization/particle_plots.py
--- a/yt/visualization/particle_plots.py
+++ b/yt/visualization/particle_plots.py
@@ -293,6 +293,7 @@ def __init__(
             window_size=window_size,
             aspect=aspect,
             splat_color=splat_color,
+            geometry=ds.geometry,
         )
 
         self.set_axes_unit(axes_unit)
diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -195,6 +195,8 @@ def __init__(
         fontsize=18,
         aspect=None,
         setup=False,
+        *,
+        geometry="cartesian",
     ):
         self.center = None
         self._periodic = periodic
@@ -216,6 +218,20 @@ def __init__(
         super().__init__(data_source, window_size, fontsize)
 
         self._set_window(bounds)  # this automatically updates the data and plot
+        if (
+            geometry
+            in (
+                "spherical",
+                "cylindrical",
+                "geographic",
+                "internal_geographic",
+                "polar",
+            )
+            and origin != "native"
+        ):
+            mylog.info("Setting origin='native' for %s geometry.", geometry)
+            origin = "native"
+
         self.origin = origin
         if self.data_source.center is not None and not oblique:
             ax = self.data_source.axis
@@ -1947,16 +1963,6 @@ def __init__(
         if field_parameters is None:
             field_parameters = {}
 
-        if ds.geometry in (
-            "spherical",
-            "cylindrical",
-            "geographic",
-            "internal_geographic",
-            "polar",
-        ):
-            mylog.info("Setting origin='native' for %s geometry.", ds.geometry)
-            origin = "native"
-
         if isinstance(ds, YTSpatialPlotDataset):
             slc = ds.all_data()
             slc.axis = axis
@@ -1983,6 +1989,7 @@ def __init__(
             aspect=aspect,
             right_handed=right_handed,
             buff_size=buff_size,
+            geometry=ds.geometry,
         )
         if axes_unit is None:
             axes_unit = get_axes_unit(width, ds)
@@ -2163,15 +2170,6 @@ def __init__(
         normal = self.sanitize_normal_vector(ds, normal)
 
         axis = fix_axis(normal, ds)
-        if ds.geometry in (
-            "spherical",
-            "cylindrical",
-            "geographic",
-            "internal_geographic",
-            "polar",
-        ):
-            mylog.info("Setting origin='native' for %s geometry.", ds.geometry)
-            origin = "native"
         # If a non-weighted integral projection, assure field-label reflects that
         if weight_field is None and method == "integrate":
             self.projected = True
@@ -2220,6 +2218,7 @@ def __init__(
             window_size=window_size,
             aspect=aspect,
             buff_size=buff_size,
+            geometry=ds.geometry,
         )
         if axes_unit is None:
             axes_unit = get_axes_unit(width, ds)


Test patch: