Lock-exchange tank used to expose fish to an acute heterothermal environment.

(A) Side-view of the experimental tank during the acclimation phase (15 min), with fish in the left compartment exposed to water at their acclimation temperature (12 °C) separated by a closed gate from the dyed water of a different temperature in the right compartment. Red ellipses indicate the locations of four trout parr tested simultaneously. Fish were tracked continuously based on video recordings of the lateral view of the entire tank. (B) The treatment phase was initiated by rapidly removing the gate, allowing the cold water to slowly intrude below the warmer water (1–2 min), thereby exposing the fish to a heterothermal environment. A sharp thermal interface (dashed line) separated upper, warmer water from lower, colder water. Within the first two minutes, the thermal interface moved laterally and afterwards spanned the entire lateral extent of the tank. Over time, the interface increasingly stabilized around the central depth of the tank. The movement of the interface was much slower than fish swimming speeds (Supplementary Figs. 3 and 20). The frame used here for illustration was captured in a cold-water treatment, 11 min after gate removal. (C) Trajectory of a single fish over 18 min (treatment TR3, Tbottom = 6 °C, Ttop = 12 °C). The trajectory is color-coded according to the temporal phase of the experiment (see D). (D) The different phases of the experiments. After 15 min acclimation, the gate was removed and it took approximately 2 min to establish a horizontal thermal interface spanning the entire tank length. To allow the analysis of temporal trends in fish behavior, the dataset was divided into four periods of equal duration: acclimation, and experimental phases p1–p3. For a list of treatments, see Supplementary Table 1.

Fish avoid the cold, but not the warm.

(A) Side-view of the (two-dimensional) swimming trajectory of a fish (colored line) in relation to the thermal interface (dashed black line). Black dots along the trajectory indicate the center of gravity of the fish during an example segment of 12 s. Colors indicate elapsed time, from blue to yellow. (B) Definition of warm- and cold-water excursions within a trajectory based on the fish’s instantaneous vertical distance to the thermal interface, D(t). An excursion starts and ends when the fish crosses the thermal interface. (C and F) Probability density functions of normalized fish depth Ynorm during the final 6 min (p3) of the experiments for all cold-water (TR1–TR4, C) and all warm-water (TR6–TR9, F) treatments. Data was aggregated at the treatment level, hence each line represents data from 20 fish, tested in groups of 4 individuals in 5 separate experiments. Tbottom and Ttop indicate the water temperature below and above the thermal interface. The depth was normalized so that Ynorm = 0 is the water surface and Ynorm = 1 indicates the bottom of the tank. (D and G) Probability density functions of fish depth for TR2 (D) and TR7 (G), separated according to the four phases of analysis (acclimation phase and experimental phases p1–p3; see Fig. 1D). Data were aggregated at the treatment level as in C and F. Data for other treatments are shown in Supplementary Fig. 5. (E and H) Vertical distance to the interface, D, as a function of time for each cold-water (light blue shaded region) and warm-water excursion (light pink shaded region) for TR2 (N = 980) (E) and TR7 (N = 430) (H) aggregated for all three experimental phases (p1–p3). N is the total number of cold-water excursions performed by the 20 fish. The vertical extent of the thermal gradient thickness is indicated as blue and red (see Methods). shown in red Data for other treatments are shown in Supplementary Figs. 6 and 7. For a list of treatments, see Supplementary Table 1.

Fish avoid cold water by directional upward turning.

(A) Example trajectory (12 s) with identified vertical turning points (pink triangles, downward; green triangles, upward). (B) Turning points were identified as sign changes of the time series of the vertical velocity component, vy(t). The same trajectory as in A is shown. (C) Boxplots showing the number of cold-water excursions for each cold temperature treatment. Each dot represents the median number of cold-water excursions Ñ of four individuals tested simultaneously within one experiment. Red lines indicate the median of 5 experiments. Whiskers extent to the full range of observations. The temperature treatments TR2 and TR4 differ significantly (ANOVA, p < 0.001), with pairwise t-test results as indicated (* 0.01 < p ≤ 0.05; ** 0.001 < p ≤ 0.01, see also Supplementary Table 18-20). (D and E) Swimming trajectories (gray lines) and vertical turning points (color-coded as in panel A) plotted with respect to the vertical distance to the thermal interface (black dashed line) for cold-water treatment TR2 (D) and warm-water treatment TR7 (E). The trajectories shown are from the central region (80 < X < 120 cm) of the tank, for 20 fish (5 x 4 fish per experiment). Turning points were filtered based on a vertical displacement threshold of dz > 3 cm to detect turning activity that resulted in significant vertical displacement (Supplementary Fig. 14). Data for other treatments are shown in Supplementary Figs. 12 and 13. (F and G) Difference of probability density distributions of upward turns (ρup) and downward turns (ρdown) for the entire width of the tank (0 < X < 200 cm) as a function of the distance from the thermal interface (located at = 0), for all cold (F) and warm treatments (G). The same y-axes as in panels D and E apply. The tank bottom is located at around -10 cm > > -20 cm, while the water surface is located at around 10 cm < < 20 cm (the variability being related to the initial period of time in which the thermal interface oscillates). The underlying normalized histograms are in Supplementary Figs. 14 C and E. The vertical extent of the thermal gradient thickness is indicated as blue and red (see Methods).

Fish reduce the duration and depth of cold-water excursions in larger measure the colder the water temperature below the thermal interface.

(A) Fish perform cold-water excursions in which they cross the thermal interface and swim into colder water, then turn upward to return to the warmer water. Individual cold excursions were characterized by their duration, 𝛺, and the maximum vertical distance to the thermal interface, Dmax. (B) Fish exhibit shorter durations of cold-water excursions when encountering lower water temperatures below the interface (Tbottom). The decreasing trend was statistically significant (Mann–Kendall test: for Ω͌, p < 0.001; for max, p < 0.001; Supplementary Table 6). Boxplots show the median duration of cold-water excursions for fish groups across all phases (p1, p2 and p3) within each treatment. Points represent the median of a single experiment. TR2, one outlier not shown (out of range). (C) For colder water temperatures, fish penetrate less deeply into the cold lower water. The decreasing trend was statistically significant (Mann–Kendall test: max, p < 0.001; Supplementary Table 6). Underlying distributions and histograms are shown in Supplementary Fig. 18. Equivalent plots for warm treatments are shown in Supplementary Fig. 17A,B. (D and E) Probability density distributions of the durations Ω of warm- and cold-water excursions for TR1 (D) and TR3 (E), respectively. The distributions of the warm- and cold-water excursion durations become increasingly distinct over exposure time for TR3 but not TR1. Excursions at 12 °C (above the interface) are shown in black, while excursions in the lower, colder water are depicted in the respective color. Treatment phases are indicated by line type (p1–p3). Values of n indicate the total number of excursions of each type within that phase for 20 fish (as the excursions alternate, n is equal for cold and warm excursions). Underlying histograms of D and E and other treatments are shown in Supplementary Fig. 19 and 16.

Fish swim more rapidly in the cold.

(A) Mean swimming speed when above (in warmer water) and below (in colder water) the thermal interface. Speed was standardized by the average swimming speed of each individual during the treatment phases (p1–p3). Data was aggregated at the replicate level; hence v̅̅n,t represents the average response of the fish group (four fish) within one replicate. Symbols represent the results of pairwise t-tests (ns, p > 0.05; *, 0.01 < p ≤ 0.05; ***, 0.0001 < p ≤ 0.001, see also Supplementary Table 16). Whiskers extent to the full range of observations and red lined indicate the median. The equivalent data for warm treatments are shown in Supplementary Fig. 22 and absolute swimming speeds are shown in Supplementary Figs. 20 and 21. (B and C) Probability density functions of averaged, swimming speed during cold-water excursions (B) and warm-water excursions (C) in cold treatments (TR1-TR4). Speed was standardized by the average swimming speed of each individual within each phase and n,p represents the average of this quantity over the duration of each individual excursion. The total numbers of cold-water excursions are TR1, n = 889; TR2, n = 389; TR3, n = 611; and TR4, n = 452; with identical numbers of warm-water excursions for each treatment. A kernel density estimator was fitted to the normalized histogram after log10-transforming the data. Equivalent figures for warm treatments are shown in Supplementary Fig. 23. Excursion durations were scattered against average normed swimming speed (see Supplementary Fig. 24).

(A) Photograph showing a side-view of the experimental tank in phase 2 (approximately 10 min after removal of the central gate) with four individual fish. The camera used for imaging is visible in the foreground. The dark casing obstructs the entry of natural light. Experimental animals (B); central gate to partition the tank; (C) right side of the tank with 3 temperature probes (white arrows) and dissolved oxygen probe (red arrow) (D).

Side view of temporal progression of gravity current for cold treatment.

During the acclimation phase (top panel) the water tank is partitioned into 12° C in the left compartment and 4°C (TR4) in the right compartment. After 15 minutes of acclimation the central gate is removed (here at time: t = 0) and the density difference drives a lock exchange flow with the transparent warm water flowing slowly in the upper half of the tank to the right and the dyed cold water flowing along the channel bottom towards the left (t = 0.8 minutes). After reaching the side walls of the tank, the directionality of the flow reverts and the current sloshes back and forth in the form of an internal wave (t = 1.8 – 5 minutes). A clear second and a third wave passage take place, while flow speed and wave amplitude gradually attenuate through dissipation. During these internal wave passages, the vertical height of the temperature interface remains a periodic function of time. A stationary vertical stratification (i.e. the water is practically still) is reached only after about t = 10 minutes. The start of the first treatment phase (p1) was defined as the time when the vertical gate was fully removed from the water (t = 0).

Transient movement of the thermal interface/line during experimental phases (p1, p2 and p3).

Coloured lines depict time steps of 10 seconds. The water surface is located at Y = 4 cm. The instantaneous position of the thermal interface is shown for each experimental phase (acclim., p1, p2, and p3) at a reduced temporal resolution of 0.2 Hz (the temporal resolution in the experiments was 24 Hz). The interface was approximated as a line (X,Y) for each frame. During the acclimation period (acclim: grey dots) a sealed gate was located at X = 100 cm. The interface is coloured by the respective temporal phase of the experiment (see A).

Side view of experimental setup for cold (A) and warm (B) treatment (TR2 and TR7).

The thermal interface line (black) was derived using custom made image analysis pipeline.

Probability density functions of fish depth for all cold-water (TR1–TR4, AD) and all warm-water (TR6–TR9, EH) treatments (N = 20 fish in each case), separated according to the four phases of analysis (acclimation, and the three experimental phases p1–p3).

The data was aggregated at the treatment level; hence each line represents data from 20 fish, tested in groups of 4 individuals in 5 separate experiments. Tbottom and Ttop indicate the water temperature below and above the thermal interface. The depth was normalized so that Ynorm = 0 is the water surface and Ynorm = 1 indicates the bottom of the tank.

Cold treatments, TR1-TR4.

Temporal evolution of the fish’s instantaneous vertical distance to the thermal interface D(t) within the first 25 seconds for each cold- and warm-water interval for all cold treatments. At t = 0 fish crosses the thermal interface line upwards (warm segment; upper half) or downwards (cold segment; lower half). The end of an interval occurs when the interface line was crossed again in the opposite direction.

Warm treatments TR6-TR9.

Temporal evolution of the fish’s instantaneous vertical distance to the thermal interface D(t) within the first 25 seconds for each cold- and warm-water interval for all warm treatments. At t = 0 fish crosses the thermal interface line upwards (upper half) or downwards (lower half). The end of an interval occurs when the interface line was crossed again in the opposite direction.

The average time fraction spent in 12 °C was calculated for each fish and phase (p1, p2 and p3) as Tcold / 6 minutes for incoming cold water (TR1-TR4, A) and incoming warm water (TR6-TR9, B).

Each dot represents the average of this quantity over four individuals that were tested simultaneously within one experimental replicate. The Friedman-test suggests that there are significant temporal differences within TR1 (p = 0.022). Significance levels are indicated above the plot (Dunn-test: * : 0.01 < p ≤ 0.05).

Cold treatments.

Boxplots of time fraction spent in upper half (Ynorm = 0–0.5) and lower half (Ynorm = 0.5–1) of the tank across experimental phases (acclim., p1, p2 and p3) and treatments (TR1, TR2, TR3 and TR4).

Warm treatments.

Boxplots of time fraction spent in upper half (Ynorm = 0–0.5) and lower half (Ynorm = 0.5–1) of the tank across experimental phases (acclim., p1, p2 and p3) and treatments (TR6, TR7, TR8 and TR9).

Derivation of vertical turning points.

(A) To smoothen the fish’s vertical position signal (red line), a fifth order polynomial was fitted to a moving window of 50 consecutive time points (black line). This is a standard practice in particle tracking to filter out noise (e.g. Lüthi et al. JFM 2005). Therefore the SAVGOL function (python: scipy.signal.savgol_filter) was applied on the raw output (black line) from the tracking software. Upward turning (green triangles) were detected as sign change (from negative to positive) of the derivative of the smoothed signal. Downward turning (red triangles) were detected via sign change (from positive to negative). (B) Occurrence of turning points after gate removal (at t = 0) for an individual fish in cold treatment (TR3).

Cold treatments.

Swimming trajectories (black lines) relative to the thermal interface (red line) for all fish across cold treatments (TR1 – TR4, A-D). The horizontal axis depicts the horizontal position in centimetres; the vertical axis depicts the instantaneous distance from the thermal interface. For D > 0 fish is located at a distance D [cm] above the interface and for D < 0 the fish is located below the temperature interface. Red and green triangles depict large downward and upward turns, respectively (see Supplementary Fig. 11 and Fig. 14 for derivation).

Warm treatments.

Swimming trajectories (black lines) relative to the thermal interface (red line) for all fish across cold treatments (TR6 – TR9, A-D). The horizontal axis depicts the horizontal position in centimetres; the vertical axis depicts the instantaneous distance from the thermal interface. For D > 0 fish is located at a distance D [cm] above the interface and for D < 0 the fish is located below the temperature interface. Red and green triangles depict large downward and upward turns, respectively (see Supplementary Fig. 11 and 14 for derivation).

(A) Normalized histogram of the vertical distance dz between all consecutive turning points for all treatments (depicted by colors). A threshold of dz = 3 cm was used to differentiate turning events that result in small, cruising related vertical displacements (B,D) from vertical turns that resulted in large vertical displacement (dz > 3 cm) (C, E).

Number of performed cold-water excursions (A) and warm-water excursions (B) over time (p1 – p3).

Boxplots show the median, whiskers extend to the full data range and the boxes are limited by 25th and 75th percentiles. Each dot represents the median across 4 individuals, tested simultaneously.

Probability density function of the duration of warm- and cold-water excursions for cold (A-D) and warm treatments (E-H) and across treatment phases (p1, p2 and p3).

As a reference for comparison, black lines depict trajectory excursions in 12°C. Coloured lines show respective distributions in treatment water temperatures below (A-D) or above the thermal interface (E-H).

Warm-water excursions during warm treatments (TR6-TR9).

For each quantity, the median of 4 individuals (tested simultaneously) was considered; hence each dot represents a single experiment. (A) Boxplots of the maximum (upwards) distance to the interface of warm-water excursions. The median of Dmax was applied to all excursions performed by an individual fish and for all phases (p1, p2 and p3). (B) Boxplots of the median duration of cold-water excursions for fish. The median of Dmax was applied to all excursions performed by an individual fish and for all phases (p1, p2 and p3). Each dot represents a single experiment. (C) Boxplot of the median number of warm-water excursions (upwards) for fish groups across warm treatments and experimental phases (p1, p2 and p3). Each dot represents the median response of four fish in a single experiment. Blue lines indicate the median, boxplots are limited by the 25th and 75th percentiles. Whiskers extent to the full range of observations.

Probability density function of maximum distance to interface line Dmax for cold (left) and warm (right) excursions for all treatments.

Underlying normalized histograms are shown in thin colored lines.

Underlying probability density distributions of the durations Ω of warm- and cold-water excursions for TR1 (A) and TR3 (B), respectively.

The distributions of the warm- and cold-water excursion durations become increasingly distinct over exposure time for TR3 but not TR1. Excursions at 12 °C (above the interface) are shown in black, while excursions in the lower, colder water are depicted in the respective color (green: Tbottom = 10 °C; blue: Tbottom = 6 °C. Treatment phases are indicated by line type (p1–p3). Values of N indicate the total number of excursions of each type within that phase for 20 fish (as the excursions alternate, N is equal for cold and warm excursions). Underlying distributions are shown as histograms.

Probability density of absolute swimming speeds V per experimental phase (ac: acclimation; p1, p2 and p3) and treatment.

Cold treatments (A-D) and warm treatments (E-H). Each lines indicates the normalized distributions of N = 6 min x 60 s x 24 fps x 20 fish = 172’800 observations.

Extreme swimming speeds above V = 20 cm/s for TR1-TR4 (A-D).

Black histograms show all observations above the thermal interface (Ttop = 12 °C). Colored histograms display all observations below the thermal interface (in colder water). Dashed vertical lines depict literature thresholds for burst swimming speeds of rheophilic fish based on temperature (orange line: T = 12°; red line: T = 4 °C), body length (3.6 cm), and swimming durations (5 seconds) as proposed by (77) (see also Supplementary Text 4). High swimming speeds were most frequent during cold-water occupation in colder treatments (TR2-TR4).

Mean swimming speed when above (in warmer water) and below (in colder water) the thermal interface.

Speed was standardized by the average swimming speed of each individual during the treatment phases (p1–p3). Data was aggregated at the replicate level; hence v̅̅n,t represents the average response of the fish group (four fish) within one replicate. Symbols represent the results of t-tests (ns, p > 0.05; *, 0.01 < p ≤ 0.05; ***, 0.0001 < p ≤ 0.001, see also Table S17). Whiskers extent to the full range of observations and red lined indicate the median.

Averaged phase normalized swimming speed during warm water excursions (A) and cold-water excursions (B) in warm treatments (TR1, TR2, TR3 and TR4).

Data has been transformed to log10 and a Kernel density estimator was fitted to the normalized histogram.

Normalized swimming speed n,p averaged over excursions plotted as a function of the duration Ω of each cold (blue points) and warm (red points) water excursion for all cold (A - D) and all warm treatments (E - H).

To control for temporal trends, speed was standardized by the average swimming speed of each individual within each phase. Fitting a 2D Kernel density estimator to the point clouds (red and blue lines) reveals for cold treatments with TBottom ≤ 8 °𝐶 (TR2-TR4, B-D), clusters separate with respect to swimming speed (y-axis) and duration (x-axis).

(A) Violinplots of simulated body temperature Tbody after each performed cold-water excursion for cold-water treatments (TR1-TR4). Each dot is one excursion, red line indicates the median and n is the number of performed excursions by 5x4 = 20 fish within each treatment. The model (see SI Text) assumed fish body mass of m = 4 gramm, initial body temperature of T0 = 12°C and a cooling rate coefficient of k = 1.373 min-1. (B) Boxplot of the median body temperature (body) after cold-water excursions for each experimental replicate. Red line indicates the median across experimental replicates.

Cumulative time spent in incoming cold water (A) and warm water (B).

Thick lines represent the averaged cumulative time spent in cold water on the replicate level. Thin lines depict the 84thand 16th percentile across experimental replicates. Two cold shocked individuals (in TR2) were excluded from the average as outliers. Fish displayed opposing responses to incoming warm and cold water over time. Namely, fish decreased the occupancy of cold water, while in warm treatments fish enhanced occupancy of warm water (see also Fig. 8).

Cold treatments.

Time traces of temperature [°C] and dissolved oxygen concentration [mg/L] in experiments during acclimation (left) and treatment phase (right). Temperature (Probe 1-6) was measured at three different depths (red, orange, blue) at both side walls of the experimental tank for all experiments (upper plots). Dissolved oxygen was measured on both sides of the tank. All measurements were continuously obtained at a frequency of 5 Hz.

Warm treatments.

Time traces of temperature [°C] and dissolved oxygen concentration [mg/L] in experiments during acclimation (left) and treatment phase (right). Temperature (Probe 1-6) was measured at three different depths (red, orange, blue) at both side walls of the experimental tank for all experiments (upper plots). Dissolved oxygen was measured on both sides of the tank. All measurements were continuously obtained at a frequency of 5 Hz.

The theoretical large-scale gravitational velocity 𝑢0, plotted against the cold current propagation speed 𝑢-obtained from experimental videos of cold-water treatments (TR1–TR4)

A linear regression fit (red dashed line) is shown. (B) The Kolmogorov length 𝜂 as a function of the temperature contrast Δ𝑇. The black dots represent experimental data, while the red dashed line indicates a power-law fit. (C) Temporal evolution of the thermal interface thickness, influenced by turbulence and diffusion. A 2D numerical simulation was conducted over a 20-minute period, using an initial interface thickness estimated as 𝛿k ⋍ 3.7 𝜂 (see Methods). The spatial domain was discretized into 1 mm2 grid cells (dx = dy = 0.001 m) and a constant thermal diffusivity of D = 1.43e-07 m2/s was assumed. Results indicate that, over the course of the experiment, the gradient thickness 𝛿k increased over time, rising to values larger than the length the individual fish.

Cold treatments.

Trajectories for all fish during acclimation phase (A - D) und treatment phases (E - F).

Warm treatments.

Trajectories for all fish during acclimation phase (A - D) und treatment phases (p1, p2 and p3, E - F).

Tracking success rate for each individual during experimental phases (p1, p2 and p3).

We captured the trajectory for on average 99% of the time. Low values are explained by fish occluding over longer periods of time (without moving) or being located behind the dissolved oxygen probes. For these cases a second camera perspective was used to resolve the occlusions and data gaps were closed using linear interpolation. The open-source tracking software “TRex” (67) was used to track fish at a temporal resolution of 24 frames per second.

(A) Rotated and cropped RGB image of the side camera (GoPro hero7). (B) Subsection of RGB image. (C) Red channel. The turquoise dot indicates the fish’s center of gravity for this time instance, derived from tracking in TRex. (D) Green channel. Red line indicates the thermal interface, derived by custom made python scripts.

(A and B) Probability density functions of fish depth during experimental phases (acclim., p1, p2 and p3) of the experiments for cold-water treatment 3 (TR3, A, N = 16 fish) and its control without the addition of blue dye (TR5, B, N = 16 fish). Both cases had identical thermal conditions (Tbottom = 6 °C, Ttop = 12 °C) above and below the thermal interface. The depth was normalized so that Ynorm = 0 is the water surface and Ynorm = 1 indicates the bottom of the tank. Due to a camera failure one of the control experiments could not be processed, hence the control is based on 4 replicates, while TR3 is based on 5. (C) Boxplots aggregated on the fish group level did not show significant differences with regards to the vertical relocation across experimental phases.

2D-swimming trajectories for TR3 (A and C) and its control without blue dye (TR5, B and D) during 6 min acclimation (A and B) and later experimental phases (p1, p2 and p3, C and D).

Both treatments had identical temperature conditions (Tleft = 12 °C; Tright = 6 °C).

Image operations in python (opencv) to derive the instantaneous position of the thermal interface.

As the lock exchange flow is primarily a 2D phenomenon and the width of the tank is narrow (20 cm) as compared to its length (200 cm), the temperature interface was approximated as a 2D line (X(t),Y(t)). The interface coordinates were derived for each time frame using a custom-made image analysis pipeline (python, opencv).

Vertical distance to thermal interface line.

The temporal progression of the vertical distance to the thermal interface line, D(t), is shown for 4 individuals in an experiment of cold treatment 3 (TR3) and warm treatment 8 (TR8). The vertical gate was removed at time t = 0. Negative values of D(t) depict times when the center of gravity of the tracked fish was below the thermal interface hence in the colder water and vice versa. Each sign change of D(t) depicts an interface crossing. Data gaps within the first two minutes arise from the fact that the gravity current did not yet fully span the entire horizontal dimension of the tank (i.e., in this period was excluded from our analysis, fish may neither be located below nor above but laterally displaced from the thermal interface). Shortly after the current reaches the wall, maximum distances |𝐷(𝑡)| of up to 20 cm are possible (see also Movie 1). After the vertical stratification becomes stationary (t ≈ 10 minutes), the interface is approximately located at half the tank depth (h = 14 cm) and values for |𝐷(𝑡)| are below 14 cm.

Example time traces illustrating the derivation of fish swimming speed (V) and normed swimming speed Vnorm from the raw tracking output.

(A) Raw trajectory output from tracking software (TRex) for a single fish during 1 minute of treatment 3 (Tbottom = 6°C). (B,C) Horizontal and vertical velocity component (vx, vy) derived from raw output (blue line) and after applying the spline smoothing (Lüthi et al. 2005). (D) Absolute 2D-swimming speed V based on smoothed velocity components. (E) Normalized swimming speed Vnorm speed derived as Vnorm = V(t) / Vmean. The dashed line indicates the average swimming speed during the entire treatment duration (p1, p2 and p3 combined).

Violin plots showing the vertical distance from the thermal interface at which up-turning events occurred during cold-water treatments (TR1–TR4; panels A–D).

Each black dot represents a single up-turning event, and the red line indicates the median distance. Data are grouped by experimental phase (p1–p3). The dashed line denotes the position of the thermal interface (0 cm), and the red shaded area indicates the estimated thickness of the vertical thermal gradient (see Methods).

Definition of treatments.

We contrasted water at the acclimation temperature (12°C) with four cold treatments (TR1-TR4) and four warm treatments (TR6-TR9) hence we varied the incoming water temperature in both directions (Table S1). Initial water temperature (T) and density (ρ) in the left (subscript: left) and right (subscript: right) compartments of the tank for each treatment. Treatment 5 (TR5) was the control treatment, conducted without the dye (see Supplementary Figs. 33 and 34).

Tracking parameters used for fish tracking in TRex software.

Detailed description of parameter can be found here: https://trex.run/docs/parameters_trex.html

Percentage of all captured cold and warm excursions shorter than 10 seconds for all phases (p1, p2 and p3) of each treatment.

Input to body-cooling model.

Summary of fish body temperature at beginning of cold-water excursion (Tb) and ambient water temperature (Ta) during cold-water excursions.

Mann-Kendall test.

Input data: Median distance max (in centimeters) and median durations Ω͌ (in seconds) across all treatments and experimental replicates.

Mann-Kendall test result.

A p-value lower than some significance level (common choices are 0.10, 0.05, and 0.01), indicates statistically significant evidence that a trend is present in the data. We found in both cases p < 0.001.

Friedman test within each treatment, < time-fraction spent in 12°C >, Tr depicts the treatment temperature initially in the right compartment of the tank.

TR1, Dunn-test

TR3, Dunn-test

TR7, Dunn-test

Friedman test, result, median number of excursions over time for all all-treatments.

TR1, Dunn-test (post-hoc)

TR9, Dunn-test (post-hoc)

Shapiro-Wilk test for cold treatments.

Group averaged and normed swimming speeds v̅̅n,t for different temperatures (above and below interface).

Shapiro-Wilk test for warm treatments.

Group averaged and normed swimming speeds for different temperatures (above and below interface).

t-test results for cold treatments.

ns: not significant; * : 0.01 < p ≤ 0.05; *** : 0.0001 < p ≤ 0.001

t-test results for warm treatments.

Median number of cold-water excursions Ñ of 4 fish tested simultaneously within each experimental replicate. Shapiro-Wilk-test results.

One-way ANOVA test result

Pairwise t-test result