Plants are sociable creatures. You’ll rarely find them growing all on their own in a natural environment. As gardeners know, you clear the tiniest patch of soil and the moment you turn your back, a number of plants move in to keep your carefully raised seedlings company. These natural colonies of vegetation don’t arrive by accident. Plants that cluster together have plenty in common from the start, as they enjoy the same environment and growing conditions. And they often pal up. Climbers in rainforests cozy up to tall, upright plants that can give them a leg-up towards the light, and mistletoe snuggles into oak trees for support, nutrients and water.

These partnerships help one of the plants—sometimes both—grow better, so it’s common sense to look for similar marriages of convenience in the garden and harness the benefits they bring. Grouping beneficial plants together, or companion planting, is not well understood, and there’s scant scientific research to explain how it works. But the few studies there have been all seem to back up the theory that plants grow best in polycultures—multiple species, all mixed in together.

A field experiment in New Zealand, for example, planted buckwheat under commercial vineyard grapevines to attract wasps that prey on the moth species that was damaging the grapes. The result: moth populations plummeted and the grapes were harvested largely unblemished. A smaller experiment at the University of Central Florida demonstrated that planting sage among cabbage plants measurably reduced the number of pests.

Most of what we know about companion planting is passed down from gardener to gardener as anecdotal, experience-driven folklore. Some of these partnerships work, and a few are just old wives’ tales. Luckily, the best companion planting is a matter of simple common sense. It’s obvious, for example, that planting in straight rows with large spaces between plants and growing in monocultures goes directly against natural plant growth patterns. This traditional kind of gardening is like hanging a big neon sign over your plants saying, “Come get me.” You’re giving insects unfettered access to a feast of goodies, all concentrated in one place for their convenience.

Mimic nature more closely, though, by mixing vegetables with flowers, herbs and other types of edibles, and you’ll confuse and distract pests trying to find their way through strange scents and unappealing textures. Make some of those plants ones that actively repel or kill those pests and you have a natural control system to protect your produce.

Many pests find their target simply by sniffing it out. Most notorious for this is the carrot fly, which can detect a whiff of crushed carrot foliage from up to a mile away. Disguise the smell, and it stands to reason that the pest will find it more difficult to track down its prey. Pungently-scented alliums, including onions, chives, leeks and garlic, are good partners for carrots. Plant them in alternating rows and in one of those happy coincidences of nature, the onions put off carrot fly and the carrot smell is disliked by onion flies, too.

Gardeners sometimes report poor results from this companionship. Often the difficulty is not with the combination but with the quantities planted. One onion won’t put up much of a scent screen, but double rows of thickly planted shallots and onions on each side of the carrots, hidden safely in the middle, give you full-power protection. Providing shelter so the odor is not dissipated in the wind also helps.

Pungent companions for carrots and other plants vulnerable to flying pests, such as tomatoes, also include mint (planted in containers to restrain its notoriously rampant habits) and French marigolds. Marigolds planted at the feet of tomatoes are effective in fending off whiteflies.

Some scented companions also benefit the plant they’re sharing soil space with. The thyme-like herb summer savory is a well-known partner for fava beans in the kitchen. In the garden, savory’s strong smell keeps aphids off bean tips and is said to improve the flavor of the beans. Basil is another plant that enriches the flavor of its companion if it’s planted near tomatoes. You might not want to pick the results, though. It also attracts whiteflies away from the tomatoes and becomes absolutely infested.

This kind of decoy planting to lure pests away from your cherished vegetables is another useful way of pairing plants, if a little harsh on the decoy. Nasturtiums are often used this way: most pests seem to adore them above anything else and will cheerfully abandon more desirable crop plants if they’re nearby. Plant nasturtiums at the feet of fava beans to lure away blackflies, and near cabbages so butterflies are tempted away from the brassicas to lay eggs on the nasturtium leaves instead.

Use decoy plants with care, though. Let the pests enjoy them too much and you’ll just be providing nursery facilities where they can breed. Then, when pests run out of room on decoy plants, they’ll move straight back to your veggies in redoubled numbers. When your nasturtiums start developing a pest problem, deal with it just as you would on your vegetable crops, with sprays of insecticidal soap or by picking off eggs and caterpillars from the leaves.

Pest-eating Plants

The most valuable companions of all are the small and select group of plants that are living pesticides. They not only deflect pests, they actively kill them, reducing populations and often eliminating the problem altogether. Keep carnivorous Sarracenia or butterworts like Pinguicula moranensis var. caudata in a greenhouse and whiteflies meet a gruesome end.

Extracts of the 6-ft.-tall Mexican marigold, Tagetes minuta, are currently undergoing trials as an all-purpose organic insecticide. The plant exudes a little-understood chemical from its roots that kills off eelworms, making it an ideal companion for potatoes. Even better, it’s toxic to many perennial weeds, too. There’s anecdotal evidence that this giant plant will clear a bed of bindweed, couch grass or ground elder.

Pollinator Magnets

Not all types of insects are undesirable, of course. We’re dependent on pollinating insects to produce a third of the food we eat, from beans and peas to zucchini and strawberries. And many visiting insects are your allies in the fight against pests, hunting down and consuming aphids, caterpillars and mealybugs by the thousands.

Companion planting helps ensure there are good populations of friendly bugs around. Brightly colored flowers, especially in yellow and orange, act like magnets for insects. Hoverflies seem particularly partial to pot marigolds and once they arrive in your garden, they will happily pollinate your bean flowers.

What’s more, the average hoverfly larva eats around 800 aphids in its lifetime. If you plant dill and fennel, you’ll also invite ladybugs, famous for their voracious appetite for aphids but also partial to scale insects and spider mites.

Plant heavily scented plants like catmint under plants that need a lot of pollinating, such as cherry trees, and grow scented sweet peas up supports alongside pole beans to double the attraction for bees. It’s well worth the extra effort, as full pollination increases yields by up to 70%.

You Scratch My Back...

Companion planting isn’t just about pest control, though. Plants can help each other in more direct ways by providing complementary services so each species grows better.

The classic partnership is the three sisters technique, practised for centuries by the Iroquois and still used today. Three crops are planted together: corn, pole beans and squash. All help each other in a symbiotic relationship that benefits every plant in the mix. The beans, like all legumes, use bacteria in root nodules to “fix” nitrogen from the air and deliver it to the soil, acting as a natural fertilizer.

That’s great news for greedy feeders like corn and squash, which relish the rich conditions provided by the bean. In return, corn provides a tall stem for the bean to climb, and the squash romps around on the ground, its giant leaves shading the soil’s surface and reducing evaporation while also suppressing weeds.

These “you scratch my back, I’ll scratch yours” combinations are good, common sense gardening. Taller plants create shade essential for leafy vegetables like lettuce, spinach and Swiss chard, which bolt in hot, dry conditions. Under the canopy of tall peas and pole beans, these cool-loving plants grow lush and leafy. They’ll also relish the nitrogen-fixing goodness provided by the legumes’ roots.

Planting living mulches of ground-cover plants keeps down weeds, too. Any low-growing, spreading flowers or vegetables will do. Plant them densely under taller plants and they’ll out-compete any weed, and shade the soil’s surface so less water evaporates in sunshine. The fast-growing legume red clover is one of the best—planted under cabbages it covers the ground, fixes nitrogen to fertilize the brassicas, and flowers profusely to bring in insects, which also happen to enjoy eating brassica pests like mealybugs.

Some ground-covering plants are too boisterous and out-compete their companions. Nasturtiums, for example, make great living mulches, but only under already-tall plants like corn or kale, doubling their usefulness by repelling aphids as well. But plant them among shorter, more delicate vegetables like leeks, and they’ll quickly swamp them.

Bad Companion Plant Combinations

Some plants don’t like each other at all. The need to compete in a plant-eat-plant world has led some plants to turn bad, developing characteristics that actively inhibit plants nearby from growing. This is called allelopathy.

Walnut, hickory and eucalyptus trees are well-known allelopathic plants. The majority of vegetation growing near a newly-planted walnut tree turns yellow, wilts and eventually dies. This is the effect of a chemical called juglone, found in all parts of walnut trees and toxic to most other plants. This is survival of the fittest in action. Prevent other plants from germinating and you have the whole place to yourself, with no competition for water, light or nutrients.

Even desirable kitchen garden plants like fennel can be decidedly antisocial. This tall, feathery and spicily scented herb has plenty of good qualities—for one, the ability to attract beneficial insects—but it also has a tendency to release substances that prevent other plants from germinating nearby, so never grow it by a seed bed.

A plant doesn’t have to be allelopathic to be a bad partner. Some combinations just clash. Peas and beans often suffer if planted near onions. The powerful anti-bacterial qualities of onion roots kill off the bacteria that helps legumes fix nitrogen, so the onions lose out on nutrients and without those bacteria, peas grow stunted.

Luckily, these dysfunctional relationships are in the minority, and most plants get along just fine. So, experiment and have fun with different combinations.