Skip to content
7 changes: 2 additions & 5 deletions docs/iris/gallery_code/oceanography/plot_atlantic_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ def main():
theta_1000m = theta.extract(depth_cons & lon_cons & lat_cons)
salinity_1000m = salinity.extract(depth_cons & lon_cons & lat_cons)

# Plot these profiles on the same set of axes. In each case we call plot
# with two arguments, the cube followed by the depth coordinate. Putting
# them in this order places the depth coordinate on the y-axis.
# Plot these profiles on the same set of axes. Depth is automatically
# recognised as a vertical coordinate and placed on the y-axis.
# The first plot is in the default axes. We'll use the same color for the
# curve and its axes/tick labels.
plt.figure(figsize=(5, 6))
temperature_color = (0.3, 0.4, 0.5)
ax1 = plt.gca()
iplt.plot(
theta_1000m,
theta_1000m.coord("depth"),
linewidth=2,
color=temperature_color,
alpha=0.75,
Expand All @@ -65,7 +63,6 @@ def main():
ax2 = plt.gca().twiny()
iplt.plot(
salinity_1000m,
salinity_1000m.coord("depth"),
linewidth=2,
color=salinity_color,
alpha=0.75,
Expand Down
13 changes: 7 additions & 6 deletions docs/iris/src/userguide/regridding_plots/interpolate_column.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import iris
import iris.quickplot as qplt
import iris.analysis
import matplotlib.pyplot as plt
Expand All @@ -12,8 +11,13 @@

# Interpolate the "perfect" linear interpolation. Really this is just
# a high number of interpolation points, in this case 1000 of them.
altitude_points = [("altitude", np.linspace(400, 1250, 1000))]
scheme = iris.analysis.Linear(extrapolation_mode="mask")
altitude_points = [
(
"altitude",
np.linspace(min(alt_coord.points), max(alt_coord.points), 1000),
)
]
scheme = iris.analysis.Linear()
linear_column = column.interpolate(altitude_points, scheme)

# Now interpolate the data onto 10 evenly spaced altitude levels,
Expand All @@ -27,7 +31,6 @@
# Plot the black markers for the original data.
qplt.plot(
column,
column.coord("altitude"),
marker="o",
color="black",
linestyle="",
Expand All @@ -39,7 +42,6 @@
# Plot the gray line to display the linear interpolation.
qplt.plot(
linear_column,
linear_column.coord("altitude"),
color="gray",
label="Linear interpolation",
zorder=0,
Expand All @@ -48,7 +50,6 @@
# Plot the red markers for the new data.
qplt.plot(
new_column,
new_column.coord("altitude"),
marker="D",
color="red",
linestyle="",
Expand Down
8 changes: 5 additions & 3 deletions lib/iris/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,11 @@ def _get_plot_objects(args):
# If a single cube argument, and the associated dimension coordinate
# is vertical-like, put the coordinate on the y axis, and the data o
# the x.
if isinstance(v_object, iris.cube.Cube) and iris.util.guess_coord_axis(
u_object
) in ["Y", "Z"]:
if (
isinstance(v_object, iris.cube.Cube)
and isinstance(u_object, iris.coords.Coord)
and iris.util.guess_coord_axis(u_object) in ["Y", "Z"]
):
u_object, v_object = v_object, u_object
u, v = v, u

Expand Down