Data from: Matching habitat choice could be brightness-based instead of hue-based in green–brown polymorphic grasshoppers
Data files
Feb 26, 2026 version files 23.68 MB
-
CabonAndSchielzeth2026_MHCgrasshoppers_DataAndAnalyses.zip
23.67 MB
-
README.md
6.95 KB
Abstract
Some prey species have evolved background matching, that is, they resemble their surrounding environment in terms of colour and/or brightness. When prey populations inhabit patchy environments, they may even have evolved specialised phenotypes: each phenotype matching a specific subset of patches. To benefit from the match between their phenotype and this subset of patches, individuals should preferentially select patches within that subset, a process known as matching habitat choice. Matching habitat choice is particularly beneficial to colour polymorphic prey populations, as it reduces individual and population-level predation risk. We tested for matching habitat choice in green-brown polymorphic grasshoppers using experimental arenas lined with green-brown checkerboards. Because previous work suggested that grasshoppers may distinguish green and brown solely achromatically, individuals were tested on green-brown checkerboards that were either achromatically-mismatched (different luminances and hues) or achromatically-matched (same luminance, different hues). Grasshoppers selected coloured microhabitats independently of their colour morph. They preferred green patches on achromatically-mismatched checkerboards and tended to prefer brown patches on achromatically-matched checkerboards. We conclude that green-brown polymorphic grasshoppers do not engage in matching habitat choice for hue, even though they likely distinguish green and brown chromatically. We finally investigated the potential of the preferred patches to provide increased concealment from their natural predators. Both morphs were better concealed achromatically on the preferred patches. Green-brown polymorphic grasshoppers may thus perform matching habitat choice, though through brightness matching instead of hue matching. Such brightness-based habitat choice could reduce predation risk at long distances and under low-light conditions, highlighting the importance of considering both hue and brightness in studies of habitat choice for colour purposes.
Summary:
Some prey evolved background matching to evade visually guided predators. In heterogeneous environments, background matching can be met by a specialist phenotype that resembles a specific subset of the environment. Specialist phenotypes need to engage in matching habitat choice by preferentially selecting patches against which they are best concealed to optimise their fitness. Theory predicts that matching habitat choice can help maintain adaptive genetic polymorphisms. Matching habitat choice could then contribute to the maintenance of the green–brown polymorphism in orthopterans, for which balanced maintenance has been argued, buthas yet to be mechanistically explained. We tested matching habitat choice by green–brown polymorphic grasshoppers in experimental arenas covered with green–brown checkerboards that are achromatically-matched or achromatically-mismatched. Our results show that instead of selecting microhabitats whose colour matches their phenotype, grasshoppers prefer green patches independently of their colour morph, but only on the achromatically-mismatched checkerboard. This indicates that grasshoppers discriminate green and brown only achromatically. Based on visual modelling, we show that both morphs likely perceive themselves better camouflaged achromatically against the green than against the brown patch, and so do their predators. We conclude that green–brown polymorphic grasshoppers do not engage in background matching behaviour for colour. Matching habitat choice is, therefore, unlikely to contribute to the maintenance of the green–brown polymorphism in orthopterans. Though grasshoppers might still perform background choice by matching their luminance instead of their hue. This behaviour could be protective when predators are far, preventing brown individuals standing on mismatching backgroundsfrom beinge maladapted.
Code version: R version 4.4.1
The ZIP file named CabonAndSchielzeth2026_MHCgrasshoppers_DataAndAnalyses.zip contains all data files and R script files (analyses and figures) that were used for the corresponding article (DOI: 10.1002/oik.11990). See below for details about each file.
Overview of files:
MHC_ANALYSES-2026-01-29.Rmd = Rmarkdown file with the whole script, including descriptive statistics, analyses, and plots that can be found in the corresponding article.
MHC_ANALYSES-2026-01-29.html = HTML file generated from the Rmarkdown file above (MHC_ANALYSES-2026-01-29.Rmd) that compiles all code chunks with their outputs in a single, easy-to-access and readable HTML page.
MatchingHabitatChoice_dataset.txt = data relative to the colour background choice experiment. Individuals were tested in cages floored with a 2x2 green-brown checkerboard. They were allowed to move freely for 2 weeks. Pictures of each cage were taken every 5 minutes from 7 am to 10 pm. Pictures have been processed with an AI previously trained on a small subset of those pictures. This .txt file provides the standing position of each grasshopper at each timepoint (whether it stood on a green patch, on a brown patch, or somewhere else in the cage). Each row is a single timepoint for a specific individual. For instance, the first row provides information on the standing position of the individual ZScPp001, on June 29th, 2024 (24-06-29), at 7.00 am (07h00): ZScPp001 was standing on a brown patch (see details below).
Column names and description:
- md_row = an identifier for the row, in case returning to the initial order is needed
- species = species identifier:
- Au = Acrida ungarica
- Pp = Pseudochorthippus parallelus
- cage_ID = an identifier for the experimental cage (labelled as piXXXX, where XXXX is a single 4-digit identifier ranging from 0001 to 0080)
- checkerboard = background treatment used in this cage. Can be:
- "matched" for the achromatically matched checkerboard
- "MISmatched" for the achromatically mismatched checkerboard
- GH_ID = single individual identifier. Individuals are labelled as ZScYyAAA, where:
- ZSc is fixed
- Z identifies the field generation from season 2024
- Sc identifies the experiment
- Yy stands for the species:
- Au = Acrida ungarica
- Pp = Pseudochorthippus parallelus
- AAA is a single 3-digit identifier (ranging from 001 to 110)
- morph = colour morph/colour phase at that time point
- G = green
- B = brown
- sex = sex identifier
- f = female
- m = male
- date = calendar day, formatted as YY-MM-DD
- exp_day = experimental day (ranging from 1 to 17)
- daytime = time of day, formatted as HHhMM (example: 07h00)
- sighted = whether the individual was spotted in the picture by the AI
Y = Yes
N = No
NA = picture missing or grasshopper dead
- standing_on = if sighted = Y, this column identifies where the grasshopper was standing:
G = standing on a green patch
B = standing on a brown patch
O = standing outside the colour grid (translated to NA)
- YOLOtrust = YOLO is the AI model used to detect grasshoppers in the pictures.
Although the model was reliable, errors could not be completely ruled out (e.g., identifying two grasshoppers in a picture—impossible since individuals were housed separately—or confusing a moult with an actual grasshopper).
A script was therefore built to detect inconsistencies in AI predictions:
- "trusted" = prediction consistent with expectations (e.g., 0 or 1 grasshopper detected, exactly 4 colour patches identified, etc.)
- "anomaly" = prediction required manual checking (e.g., 2 grasshoppers detected, only 3 colour patches detected, etc.)
- All anomalies were manually checked. The standing_on column provides the corrected positions and can therefore be used directly.
spectro_ColourPatches.txt
- Contains all 5 spectra measured for each colour patch (5 independent measurements per patch).
Column names and description:
- wl = wavelengths (nm)
- xxxxxxx_Ya_mb
- xxxxxxx corresponds to the background treatment:
- MISmatc = achromatically mismatched checkerboard
- matched = achromatically matched checkerboard
- Y = colour of the patch
- G = green
- B = brown
- a = identifier of the patch
- mb = measurement replicate (b ranges from 1 to 5)
spectro_GrassHoppers.txt
- Contains all 10 spectra measured for each grasshopper (5 independent measurements from the dorsal side of the pronotum and 5 from the lateral side).
Column names and description:
- wl = wavelengths (nm)
ZScXxAAAYb
ZSc is fixed
- Z identifies the field generation from season 2024
- Sc identifies the experiment
- Xx = species:
- Au = Acrida ungarica
- Pp = Pseudochorthippus parallelus
- AAA = single 3-digit identifier (ranging from 001 to 110)
- Y = pronotum side
- D = dorsal
- L = lateral
- b = replicate number of that pronotum side (ranging from 1 to 5)
Study models
Meadow grasshoppers (Pseudochorthippus parallelus) and slant-faced grasshoppers (Acrida ungarica) were collected from the field in the summer of 2024. We collected P. parallelus as adults in late June in east-central Germany, and A. ungarica as nymphs in mid-July in northern Italy. Both species are green-brown polymorphic, featuring uniform green and uniform brown individuals. A. ungarica can show longitudinal stripes that have been described as disruptive colourations (Pellissier et al., 2011), though almost none of our individuals feature such patterns. A. ungarica individuals can undergo slow ontogenetic colour changes, but note that brown-to-green transitions are noticeably more frequent than green-to-brown transitions – they represented 63% of all colour changes we observed in the present study (26 out of 41). In this study, brown-to-green transitions happened shortly before moulting, while green-to-brown transitions happened shortly after moulting.
Matching habitat choice experiment
Experimental setup
Grasshoppers were housed individually in the laboratory (located in Jena, Germany). They were housed in fauna boxes (Exo Terra Faunarium medium, 30.5 x 19.1 x 20.3 cm3) placed on their larger side to prevent the opaque lid from overshadowing the arena. Room climate conditions were controlled to reflect natural summer conditions in central Europe: 70% humidity, day temperatures around 35°C, night temperatures around 20°C, lit from above with human-visible and UV lights (Osram L BL UVA 18W/78). Light tubes were mounted directly above each arena such that illumination was maximised.
The floor of each arena was lined with a green-brown checkerboard printed on non-glossy photopaper (2 x 2 patches, 10.2 x 15 cm² for each colour patch). A total of 80 arenas were set up. Two green-brown checkerboards were used in this experiment to determine whether grasshoppers can distinguish green and brown chromatically, or solely achromatically, as suggested by Heinze et al. (2022). The colours of the first checkerboard were selected to be distinguishable by grasshoppers only chromatically, meaning they were achromatically indistinguishable (same luminance, different hues); the colours of the second checkerboard were selected to be distinguishable both chromatically and achromatically (same luminance, different hues); see Supporting Information for details on how the green and brown patches of each checkerboard were selected. We refer to the first checkerboard as the achromatically-matched checkerboard (indistinguishable on a luminance scale) and to the second checkerboard as the achromatically-mismatched checkerboard. Half of the arenas were lined with an achromatically-matched checkerboard, and the other half with an achromatically-mismatched checkerboard. The different checkerboards were evenly distributed throughout the room.
We enabled the simultaneous monitoring of all 80 arenas by developing a cluster of Raspberry Pi devices tailored to our needs (see Figure S1 for a schematic of the experimental setup). Each arena was photographed from above every five minutes between 7 am and 10 pm (181 pictures per day and arena) using a camera connected to a Raspberry Pi (Raspberry Pi camera module 3 wide, 12 MP sensor; Raspberry Pi 3 model A+). The camera was mounted on the ceiling of the arena. The Raspberry Pis were configured with instructions from the libcamera library and automated via cron jobs executing a Bash script. The picture resolution was set to 1720 by 1120 pixels. Raspberry Pis lack built-in real-time clocks and were, therefore, connected to an internet network via a router (Fritz!Box 6820 LTE) to synchronise time.
Collection of habitat choice data
We simultaneously monitored 80 P. parallelus adults in early July 202, and 80 A. ungarica nymphs in early August 2024. Sexes and colour morphs were assigned to arenas in a systematic design, distributing the different treatments evenly in the experimental room and preventing spatial clustering of similar individuals. Individuals were allowed to move freely in the arena for 15 days for P. parallelus and 17 days for A. ungarica. The extended duration for A. ungarica compensated for data loss due to a few power failures during the experiment. This experiment led to a dataset of over 425,000 pictures.
When an individual died before the end of the experiment (and as long as a replacement individual was available), it was replaced by a same-sex same-morph individual. A total of 92 P. parallelus and 87 A. ungarica were tested (45 P. parallelus on achromatically-matched background, 47 P. parallelus on achromatically-mismatched background, 43 A. ungarica on achromatically-matched background, 44 A. ungarica on achromatically-mismatched background). Fresh grass blades were provided every third day of the experiment, placing two grass pots on the opposite sides of the arena.
It has been shown for the groundhopper Tetrix undulata that disturbance increased their matching habitat choice (Ahnesjö and Forsman, 2006). We disturbed our grasshoppers every hour from 9 am to 5 pm on every third experimental day by approaching each grasshopper with a paintbrush and chasing them until they jumped. This led to 9 disturbance events per disturbance day, and 45 disturbance events in total per species. Grasshoppers were disturbed independently of whether they were standing on a colour patch matching their own colour or elsewhere in the arena.
A. ungarica nymphs need more than 7 days to develop from one nymphal stage to the next, and their colour morph is fixed at each stage. Hence, we documented their colour morph identity every third day, which ensured that no ontogenetic colour changes were missed. For each colour change that was detected, its precise timing was assessed by manually screening the relevant pictures in order to match the resolution of the colour morph assessment of A. ungarica individuals to the time resolution of our data.
Extraction of habitat choice data via AI-based object detection
In total, more than 425,000 pictures were taken during the matching habitat choice experiment, with 14% of them showing the grasshopper on a colour patch (in the remaining pictures, the grasshopper was either perched on the grasspots or on the lid). Pictures were processed using YOLOv8 models specifically trained on a subset of our pictures. YOLO (You Only Look Once) models are state-of-the-art real-time object detection algorithms (Sohan et al., 2024; Redmon et al., 2016). They use a Convolutional Neural Network to predict bounding boxes around objects and object class confidence levels from input images. A predicted box is characterised by its position within the picture (X and Y coordinates of the box centre), and its width and height (on a 0 to 1 scale, relative to the width and height of the picture). We trained a YOLOv8 model for each species individually to obtain the most accurate presence data per species. We used Python version 3.12.3 via the Python interpreter available from R version 4.4.1 to train our models (R Core Team, 2023).
YOLOv8 models were trained on 100 iterations, from 450 manually-annotated pictures. To prevent false positives in predictions, training datasets were composed of 400 pictures with a grasshopper present and 50 pictures without grasshoppers. Since our experimental conditions were well standardised, we obtained high object detection performances when feeding the model with just a few hundred pictures (see Figures S2-S4). The training pictures were manually annotated using Roboflow (https://roboflow.com/) – an online platform that helps deploy object detection models. Pictures were annotated with three object classes: green patch, brown patch, and grasshopper. Each checkerboard patch was boxed individually and classified by its colour, and the grasshoppers were boxed while excluding the antennae. When generating the training dataset via Roboflow, the 450 pictures were rescaled to a resolution of 860 x 560 pixels, without augmentation, while randomly assigning the pictures into train, validation, and test datasets (70%, 20%, and 10%, respectively).
All pictures were processed after training. Only predictions with a confidence level greater than 70% were retained. The predictions were processed by a custom R script that extracts (i) whether there is a grasshopper on the picture, and (ii) on which colour patch the grasshopper was standing, if any was detected. Anomalies in the predictions (e.g., more than one grasshopper, abnormal amount of colour patch detections) were checked and corrected manually (1971 anomalies, <0.5% of all pictures). Systematic manual checks were carried out for sequences of consecutive observations longer than 2 hours, to ensure that the model did not confound a fresh moult or a dead grasshopper with a live one. These systematic checks concerned only 93 of all sequences of consecutive observations (<0.4%), for which less than 30 contained misidentifications that were manually corrected.
Data extracted from the pictures by the YOLOv8 models gave a time series of observations of where the grasshopper was standing – that is, on a green patch, on a brown patch, or elsewhere in the arena. Since observations of grasshoppers standing elsewhere than on a colour patch were uninformative (403,593 instances over 463,360, 87%) to test for the colour patch preference, these data points were excluded from the analyses.
Statistical analyses of habitat choice data
Descriptive statistics given in the results are presented as the mean ± standard deviation, while model estimates are given as the estimate ± standard error. All analyses were performed on R version 4.4.1 (R Core Team, 2023).
It was common for both P. parallelus and A. ungarica to stand on the same patch for fairly long periods of time, noticeably longer than our five-minute data resolution. This led our dataset to be composed of sequences of consecutive observations where the grasshopper stayed on the same patch and, therefore, for which only a single decision was made per sequence. Since our main goal was to describe the decision-making behaviour of grasshoppers as to settle on a colour patch, only the first observation of each sequence of consecutive observations was kept for modelling. This yielded a total of 24,990 decisions for P. parallelus (272 ± 145 decisions per individual) and 4,839 for A. ungarica (56 ± 22 decisions per individual). Data were modelled separately for each species. We also analysed all data points without filtering the sequences of consecutive observations for their respective first observations. This additional analysis led to similar conclusions,s and we thus only present the filtered analysis below because it is based on independent decisions to settle.
To investigate the effects of grasshopper morph, of the checkerboard treatment (achromatically matched or mismatched), and of the disturbance treatment on their patch decision, we fitted Generalised Linear Mixed Models (GLMM) with a binomial error structure and logit link function using the lme4 package (Bates et al., 2015). The patch decision was modelled as a binary response variable with 1 representing the decision to stand on a green patch and 0 the decision to stand on a brown patch. We modelled the morph, the checkerboard treatment, the disturbance treatment, the dayti, me, and the sex as fixed factors. Morph was coded as -0.5 for brown individuals and 0.5 for green individuals. Checkerboard was coded as a treatment contrast with the achromatically-mismatched checkerboard as a reference. Disturbance was composed of four levels: habituation days (coded as reference; corresponding to the two first days of the experiment where no disturbance occurred), disturbance days (days where the disturbance events occurred: experimental days 3, 6, 9, 12, and 15), first chill days (every first days after disturbance days: experimental days 4, 7, 10, and 13 [and 16 for A. ungarica]), and second chill days (every second days after disturbance days: experimental days 5, 8, 11, and 14 [and 17 for A. ungarica]). Daytime was coded with a scaled linear term representing daytime spanning from 7.00 am to 10.00 pm and centred on 2.30 pm, along with a quadratic term to account for curvature. Since sex differences are widespread in behavioural experiments, we additionally tested for sex differences to control for potential sex effects: females were coded as -0.5 and males as 0.5. Whether trends would be identical in both sexes, they would be mutually confirmatory, strengthening the generalisability of results. Therefore, the intercept represents a hypothetical individual of intermediate morph and intermediate sex, tested against the achromatically-mismatched checkerboard during habituation days at 2.30 pm. Since our main interest was in the morph effect, only two-way interactions involving morph were modelled along with all main effects.
We first fitted all models with individual identity and experimental day as random effects to control for the dependency structure of our data. However, singular fits occurred in these models because of particularly low variances in experimental days (variances lower than 10-8). Since the variance was not statistically distinguishable from zero (P. parallelus [without - with]: ΔAIC = -2.00, ΔBIC = -10.13,
ΔlogLik = 0.00; A. ungarica [without - with]: ΔAIC = -2.00, ΔBIC = -8.49, ΔlogLik = 0.00), and since we did not have a specific hypothesis about the experimental day, we removed experimental day as a random effect from the models. We also tested the significance of individual identity as a random effect by likelihood ratio tests. The significance of fixed effects was tested by Wald tests.
In order to extract group means from our datasets, models analogous to the ones described above were fitted while removing the intercept to get appropriate standard errors for the group means (Schielzeth, 2010). Two types of models were fitted. The first type of models grouped data by the checkerboard treatment, sex, and morph, leading to 2 x 2 x 2 = 8 estimates of group means. These models fitted the three-way interaction between checkerboard, sex, and morph, along with the two-way interactions between morph and the linear term of daytime, morph and the quadratic term of daytime, and morph and disturbance. The second type of models grouped data by the checkerboard treatment, disturbance treatment,t, and morph, leading to 2 x 4 x 2 = 16 estimates of group means. These models fitted the three-way interaction between checkerboard, disturbance, and morph, along with the two-way interactions between morph and the linear term of daytime, morph and the quadratic term of daytime, and morph and sex. Group means and group standard errors were extracted via the summary function from the base package. With this coding, the F tests are meaningful in the sense that they test which group means are different from a null hypothesis of having no preference for either green (positive estimates) or brown (negative estimates) patches.
We aimed to compare the within-individual changes in colour patch preference for A. ungarica individuals that changed colour. We filtered the dataset to only keep individuals that changed colour and had at least 10 observations while being green and 10 observations while being brown, and performed Wilcoxon signed-rank tests.
Crypticity of colour morphsWe finally aimed to describe how cryptic our grasshoppers are on green and brown patches of both checkerboards, as seen from their visually-oriented predators (e.,g. birds and lizards, Civantos et al., 2004; Bock et al., 1992). Before the experiment, reflectance spectra (300–700 nm) of each grasshopper had been recorded. Grasshopper body parts display non-uniform colourations (Figure 1). To account for this variability, five independent spectra from the right lateral lobe of the pronotum and five others from its dorsum were collected for each grasshopper. We then averaged each set of ten spectra using the aggspec function, and replaced negative values with zeros with the procspec function (R package pavo version 2.9.0; Maia et al., 2019). This led to a total of 179 reflectance spectra.
Each spectrum has been recorded with a handheld spectrophotometer (Avantes, AvaSpec-ULS2048x16; optic fibre: FCR-7UVIR200-2-1.5X100, 1.5 mm diameter) coupled with a deuterium-halogen light source (Avantes, AvaLight-DH-S). Reflectance spectra between 300 and 700 nm were captured via the AvaSoft 7 software (Avantes, v.7.8). Measurements were taken in a dark room, calibrated using a commercial white standard (Avantes WS-2, which reflects 98% of light from 350 to 1800 nm, and 92% from 250 to 2500 nm), and configured with an integration time of 100 ms and an automatic averaging of 5 readings. Each spectrum was saved while holding the probe at a 45° angle, touching the cuticle surface. Our device always displays a narrow peak in reflectance between 654 and 659 nm. This peak represents an artefact of the device and was replaced by the average across reflectance at 650-654 nm and 659-664 nm.
The spectra of the greens and the browns selected to make up our two checkerboards (4 spectra in total) were also measured – see Supporting Information for details. We calculated for all 183 spectra – the 179 grasshoppers and the 4 different checkerboard colours – the quantum catches at each photoreceptor using the vismodel function, modelling the bird vision and the lizard vision. Given that grasshoppers inhabit open meadows, quantum catches were calculated assuming daylight illumination and without applying the von Kries colour correction. These quantum catchesweres then used to model visual contrasts between all combinations of the 179 grasshopper spectra with the 4 checkerboard patch spectra as perceived by birds and lizards. Some visual systems of birds and lizards are available from the R package pavo (Maia et al., 2019). Our birds’ vision was modelled using the average avian UV system as chromatic vision, and the achromatic vision of starlings Sturnus vulgaris. Our lizard’s vision was modelled using the chromatic vision of the ornate dragon lizard Ctenophorus ornatus, and the achromatic vision was modelled as the summed response of all photoreceptors because no lizard achromatic vision is available to our knowledge.
Each visual contrast was modelled using the coldist function (R package pavo version 2.9.0; Maia et al., 2019). We applied a Weber fraction for achromatic vision of 0.16, which is a conservative choice for estimating indistinguishability since it lies at the lower range of known Weber fractions for insects and birds (Olsson et al., 2018), and because smaller Weber fractions translate into higher discriminability (that is, lower indistinguishability) (Silvasti et al., 2021). Relative photoreceptor densities were set to 1:2:2:4 for bird vision (Maia et al., 2019), and 1:1:1 for the lizard vision, since photoreceptor densities of lizards are not available to our knowledge. We then extracted and averaged the achromatic contrasts (dL) and chromatic contrasts (dS), expressed as Just Noticeable Differences (JNDs), between pairs of grasshopper patches. JNDs are a measure of how easily a given organism can discriminate between two colours. Two colours are theoretically considered indistinguishable to a specific visual system when the contrast is smaller than 1 JND (Vorobyev et al., 2001). In practice, behavioural calibrations often find that animals can only discriminate two colours from a contrast of ≈ 2–4 JNDs, especially outside ideal conditions (Wang et al., 2022; Silvasti et al., 2021; Olsson et al., 2015).
