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. 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 D^ 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 D^ = 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 > D^ > -20 cm, while the water surface is located at around 10 cm < D^ < 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.

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 Dmax, 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: Dmax, 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).