Three (1 male, 2 female) absolutely alone in a 20g is bare minimum with NOTHING else except maybe a BN pleco as a bottom feeder. Any more than this and you need the 40g or bigger tank.
The reason they are better suited to a larger tank is they are messy fish and as such, the water parameters can go downhill very quickly, to the point of it being toxic to the fish.
They are also active swimmers and like to occasionally dart around, well mine did anyway. The 20g tank is not really suited for this given it's length. By the time you add a rock structure, driftwood (for the pleco) you dont have a lot of open swimming area.
Having a larger tank as well, also allows the fish to escape attention when required. Say a male in breeding mode, going after females who are not ready. A male will start chasing females to try and get them to spawn at a young age once he becomes sexually mature. With a 20g tank again, you do not have this room to allow sufficient areas potentially for the fish to escape. You could keep a single fish in a 20g tank but overtime it can become stressed as it has no company and these fish live naturally in small groups or harems anyway.
Naturally Lake Malawi is a rocky sandy bottom lake and as such, you should mimic this in the home aquarium. The fish does grow quite quick as well when fed the correct diet (good quality cichlid flakes, supplemented with a once a week treat of either soft boiled carrots, peas (de-shelled), zucchini and lettuce or a small amount of each).
40g Breeder tanks are not very expensive but would allow you to keep a group of 5 plus a pleco if you have fairly strong filtration of 10-15 times the tank volume. If you went the 40g route, you would get 1 male to 4 female. Anything different than this has potential problems, I had all males for a while and frequently until I got my now long sold 125g tank, separate the males when they were ready to breed as they get very aggressive to other males, same with the females, if one female matures faster than the others, she will chase the other females. The chasing will not stop until either the male/female actually gets interest from the opposite sex, this can lead to stressed, sick or injured fish or in the case 90% of the time with cichlids - dead fish unfortunately.