MCPcopy
hub / github.com/pydata/xarray / test_2d_coords_line_plot

Method test_2d_coords_line_plot

xarray/tests/test_plot.py:357–376  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

355 assert legend.get_title().get_text() == "dim_1"
356
357 def test_2d_coords_line_plot(self) -> None:
358 lon, lat = np.meshgrid(np.linspace(-20, 20, 5), np.linspace(0, 30, 4))
359 lon += lat / 10
360 lat += lon / 10
361 da = xr.DataArray(
362 np.arange(20).reshape(4, 5),
363 dims=["y", "x"],
364 coords={"lat": (("y", "x"), lat), "lon": (("y", "x"), lon)},
365 )
366
367 with figure_context():
368 hdl = da.plot.line(x="lon", hue="x")
369 assert len(hdl) == 5
370
371 with figure_context():
372 hdl = da.plot.line(x="lon", hue="y")
373 assert len(hdl) == 4
374
375 with pytest.raises(ValueError, match="For 2D inputs, hue must be a dimension"):
376 da.plot.line(x="lon", hue="lat")
377
378 def test_2d_coord_line_plot_coords_transpose_invariant(self) -> None:
379 # checks for bug reported in GH #3933

Callers

nothing calls this directly

Calls 4

figure_contextFunction · 0.85
linspaceMethod · 0.80
arangeMethod · 0.80
lineMethod · 0.45

Tested by

no test coverage detected