diff --git a/docs/examples/howto_meshplotlib/plot_xy_labels_with_shared_axes.py b/docs/examples/howto_meshplotlib/plot_xy_labels_with_shared_axes.py index d2282129cc052fb5dcaca6dc9e2d16770cefed4c..ba05f7276df2d26e5162cbf2d36afceb4ccdca79 100644 --- a/docs/examples/howto_meshplotlib/plot_xy_labels_with_shared_axes.py +++ b/docs/examples/howto_meshplotlib/plot_xy_labels_with_shared_axes.py @@ -24,7 +24,7 @@ from ogstools.meshplotlib import ( plot, setup, ) -from ogstools.propertylib import presets +from ogstools.propertylib.presets import temperature plt.rcParams.update({"font.size": 32}) @@ -33,13 +33,15 @@ setup.length.output_unit = "km" setup.combined_colorbar = False meshseries = examples.meshseries_THM_2D +mesh_a = meshseries.read(0) +mesh_b = meshseries.read(1) # %% # First, by default (without shared axes) both X and Y axes will be labeled # automatically. The default is that both axes are shared and this will be # respected. -fig = plot([meshseries.read(0), meshseries.read(1)], presets.temperature) +fig = plot([mesh_a, mesh_b], temperature) # %% @@ -50,13 +52,12 @@ fig = plot([meshseries.read(0), meshseries.read(1)], presets.temperature) # not. fig, ax = plt.subplots(2, 2, figsize=(40, 20), sharex=True, sharey=True) -plot(meshseries.read(0), presets.temperature, fig=fig, ax=ax[0][0]) -plot(meshseries.read(1), presets.temperature, fig=fig, ax=ax[1][0]) -diff_mesh = difference( - meshseries.read(1), meshseries.read(0), presets.temperature -) -plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[0][1]) -plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[1][1]) +plot(mesh_a, temperature, fig=fig, ax=ax[0][0]) +plot(mesh_b, temperature, fig=fig, ax=ax[1][0]) +diff_ab = difference(mesh_b, mesh_a, temperature) +diff_ba = difference(mesh_b, mesh_a, temperature) +plot(diff_ab, temperature.delta, fig=fig, ax=ax[0][1]) +plot(diff_ba, temperature.delta, fig=fig, ax=ax[1][1]) fig.tight_layout() # %% @@ -66,10 +67,10 @@ fig.tight_layout() # last plot related function call. fig, ax = plt.subplots(2, 2, figsize=(40, 20), sharex=True, sharey=True) -plot(meshseries.read(0), presets.temperature, fig=fig, ax=ax[0][0]) -plot(meshseries.read(1), presets.temperature, fig=fig, ax=ax[1][0]) -plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[0][1]) -plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[1][1]) +plot(mesh_a, temperature, fig=fig, ax=ax[0][0]) +plot(mesh_b, temperature, fig=fig, ax=ax[1][0]) +plot(diff_ab, temperature.delta, fig=fig, ax=ax[0][1]) +plot(diff_ba, temperature.delta, fig=fig, ax=ax[1][1]) ax = clear_labels(ax) ax = label_spatial_axes(ax, np.array([0, 1])) fig.tight_layout() diff --git a/docs/examples/howto_propertylib/plot_propertylib.py b/docs/examples/howto_propertylib/plot_propertylib.py index f93269142644b02e3574de1fa141338f795d0798..8bdf4a2fe16605c58eee731ac4b5278e172bd48d 100644 --- a/docs/examples/howto_propertylib/plot_propertylib.py +++ b/docs/examples/howto_propertylib/plot_propertylib.py @@ -27,7 +27,7 @@ presets.temperature.transform(273.15) # %% [markdown] # You can also create your own properties by creating a Scalar, Vector or Matrix -# property. The following would doesn't to any unit conversion. +# property. The following doesn't do any unit conversion. # %% custom_temperature = Scalar( diff --git a/tests/test_meshplotlib.py b/tests/test_meshplotlib.py index a814e2801123c112e75ab3c5568b6c6dfce95b62..345557cb7f043b5434fe84d698bfca2ed70926bc 100644 --- a/tests/test_meshplotlib.py +++ b/tests/test_meshplotlib.py @@ -191,28 +191,30 @@ class MeshplotlibTest(unittest.TestCase): def test_sharexy(self): """Test if labels are skipped if axis are shared""" meshseries = examples.meshseries_THM_2D + mesh_a = meshseries.read(0) + mesh_b = meshseries.read(1) fig, ax = plt.subplots(2, 2, sharex=True, sharey=True) ax = ax.flatten() plot(meshseries.read(0), presets.temperature, fig=fig, ax=ax[0]) plot(meshseries.read(1), presets.temperature, fig=fig, ax=ax[1]) - diff_mesh = difference( - meshseries.read(0), meshseries.read(1), presets.temperature - ) - plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[2]) - plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[3]) + diff_ab = difference(mesh_a, mesh_b, presets.temperature) + diff_ba = difference(mesh_b, mesh_a, presets.temperature) + plot(diff_ab, presets.temperature.delta, fig=fig, ax=ax[2]) + plot(diff_ba, presets.temperature.delta, fig=fig, ax=ax[3]) fig.tight_layout() def test_label_sharedxy(self): """Test labeling shared x and y axes""" meshseries = examples.meshseries_THM_2D + mesh_a = meshseries.read(0) + mesh_b = meshseries.read(1) fig, ax = plt.subplots(2, 2, sharex=True, sharey=True) plot(meshseries.read(0), presets.temperature, fig=fig, ax=ax[0][0]) plot(meshseries.read(1), presets.temperature, fig=fig, ax=ax[1][0]) - diff_mesh = difference( - meshseries.read(0), meshseries.read(1), presets.temperature - ) - plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[0][1]) - plot(diff_mesh, presets.temperature.delta, fig=fig, ax=ax[1][1]) + diff_ab = difference(mesh_a, mesh_b, presets.temperature) + diff_ba = difference(mesh_b, mesh_a, presets.temperature) + plot(diff_ab, presets.temperature.delta, fig=fig, ax=ax[0][1]) + plot(diff_ba, presets.temperature.delta, fig=fig, ax=ax[1][1]) ax = label_spatial_axes(ax, np.array([0, 1])) fig.tight_layout()