Unlike mammals the gender or sex of an individual fish is not always fixed from birth. Gender change is considered a form of hermaphrodism, as mentioned on the page on fish reproduction. The change is normally triggered by environmental cues, specifically as a response to the gender of other nearby members of their own species. Most species that undergo gender change live in small schools that are all of one gender except for a single dominant individual, but not all. Anenome fish live as monogamous pairs and in some Gobies the sex ratio is normally 1:1 also.
The gender change can be from male to female, or from female to male depending on species. Species that are born male and change to female are called Protandrous (proto = first, andros = male), and species that are born female and change to male are called Protogynous (proto = first,gyne = female). Gender change normally accompanies a change in size to a larger individual. Meaning that if the species is protandrous then the females are larger than the males, and if the species is protogynous then the males are larger than the females.
In Parrotfish and in some Wrasses the males and females have very different coloration, so much so that in some cases they were originally described as separate species. Such a species is called dichromatic. Thus in these species the change of gender involves not only an internal metamorphosis of the gonads and a rapid increase in size but also a change of colour.
In some groups the dominant male uses aggressive behavior to keep his attendant females submissive, and therefore female. If the dominant male is removed the most aggressive female rapidly changes to male and takes over the dominant position. In this case there are behavioral changes as well as physiological ones. Interestingly such groups sometimes contain small female colored males that hide amongst the females. When the dominant male is spawning with a female they approach slowly, using their female appearance to appease the dominant male's anger and then quickly release their sperm at the same time as the female releases her eggs. Such a male can undergo a size and coloration change to become a dominant male if the opportunity arises.
Not all sexually labile fish species live as harem groups. In some Anenome fish individuals have the option of a gender change, and all juveniles are male, but they normally live in monogamous pairs. However if the larger female of a pair dies then a juvenile (all juveniles are male) will quickly move in with the resident male, who immediately changes gender to become a female thus forming a new pair.
For the species mentioned above gender change is a once only occurrence, it happens when necessary and that is it. However in some Gobies th gender change is reversible, thus, if a group of are kept in an aquarium and all the males are removed some of the remaining females will change gender to become male. But if the unchanged females are then removed also some of the new males will change back to being females again, in this way there is always a reproductive potential within any group.