The sex of many fish species is not determined until after birth. In these species, environmental conditions such as diet, temperature, pH value, etc. determine how many young in a litter or clutch become females or males.
How, for example, the pH value affects the sex ratio in species of the Apistogramma genus is described in the symposium volume “Reproductive Biology of Aquarium Fish” from Birgit Schmettkamp Verlag.
In some fish species, sex can still change even in sexually mature fish. There are currently 22 families of bony fish known in which this can occur.
During protogynous sex change, females become males. In protandrous sex change, males become females. A sex change in both directions is also possible, as is known in many goby species.
A gender change can be triggered by various reasons. For example, when an animal is aggressively oppressed by another animal.
Experienced breeders know, for example, that animals undergoing an apparent sex change are usually inferior males who only develop the sex-specific traits when there are no other strong males around.
This strategy of not being noticed as a male is also common in some lizards. There inferior males, camouflaged as females, sneak into the harem of the dominant male and can thus produce offspring.
Sunfish have three sexes, presumably for this reason. Females, males and males that look like females. The male offspring always shows the characteristics of the father.
It is known that some toothcarp species change sex after they have reached sexual maturity. In cichlids, sex change in adulthood is only known in Crenicara punctulata.
Swordtails, Xiphophorus Helleri, are repeatedly cited as an example of sex change. However, there is no clear evidence for this. Rather, the sex of swordtails appears to be established early in the larval stage.
A study describing 2 cases of sex change in swordtails dates from 1926. Other reports of sex change in swordtails are usually based on inaccurate observations or misunderstandings.
In the case of swordtails, there are so-called early males, where you can soon see the base of the sword. Late males first grow thick and fat and only then do puberty. The late males are often mistaken for females until the gonopodium forms. You can only be sure that you have a female in front of you when you see the gestation mark. Early males and late males reportedly differ slightly in the chromosome that determines sex.
In addition, there are reports of female Swordtails that have had cubs transforming into males. Some older females develop caudal processes resembling the male gonopodium. Although the tail is not as pronounced as in males, confusion often occurs. In fact, such tailed females are still females and not males.
There is definitely sex change in saltwater fish. If you want to buy a pair of clownfish, just buy two fish. The larger clownfish automatically becomes the female. the smaller clownfish becomes the male. Both fish become sexually mature. This is also observed in some relatives of clownfish (damselfish). In the books «The Coral Reef Aquarium» Volume 3 by Fossa/Nilsen and Mergus Seewasser, Volume 6 or 7, the fish are described.