If you scan enough plants with your hand lens, eventually you'll find leaves or stems with special glands producing gummy or syrupy substances that ants seem to crave. For example, as the image at the right shows, atop the stems from which flowers and fruits of Black-eyed Pea arise there are glands secreting a kind of nectar (the yellow arrows point them out) that keeps ants coming day after day.
These ants, which attack any finger placed in their proximity -- as well as egg-laying moths and leaf-munching caterpillars -- help the peas stay bugless. When I picked the stem shown above I had to shake ants off it. However, when I took the stem home to scan, I placed it on my desk, and somehow ants in my trailer found the stem and began drinking from the glands, as you see at the left. When I picked up the stem and placed it on my scanner, the ants were so engrossed that they didn't move, so I scanned them! I could hardly believe it myself.
By the way, in the picture showing the Black-eyed Pea's flower, notice that the unopened flower arising at the top, right of the stem is torn open. This is the work of an insect, probably a Carpenter Bee, who "robbed" the flower. Without waiting for the flower to open, it simply tore away the outer petals and got the nectar without doing its pollinating job!
Most leaves of native plants are at least a little bitter. Often this bitterness repels some leaf-eating insects. If you pay attention to your neighborhood weeds, you'll eventually run into a milkweed. Milkweed leaves, you'll see, are soft and fleshy, at first glance perfect candidates as bug food. However, if you tear a milkweed leaf, a white, milky sap exudes from the wound. This sap, a kind of latex, is rich in bitter, even poisonous, chemicals called alkaloids. Naturally these alkaloids keep certain critters from eating the milkweed's leaves. To gain an idea just how many poisonous plants there are you might want to visit Wikipedia's List of Poisonous Plants page and Texas A&M's page Common Poisonous Plants and Plant Parts
As often is the case in nature, the story about the milkweed's alkaloid-rich leaves doesn't end there. Today on any good milkweed plant a backyard naturalist can hope to discover such insect goodies as Lygaeus kalmii, the Small Milkweed Bug, and the caterpillar stage of Danaus plexippus, the Monarch Butterfly. Millennia ago these species developed adaptations enabling them, much in contrast to other insects, not only to survive eating milkweed alkaloids, but even to thrive on them. Small Millkweed Bugs and Monarch Butterfly caterpillars are colorfully and boldly patterned. These gaudy looks warn birds not to eat them. The warning is appropriate because the insects' bodies contain such high concentrations of milkweed alkaloids that they are "too bitter to eat." So, here's a case of insect species not only evolving so that they can survive a plant's poisons, but actually using those poisons to their own advantage!
If you ever run into the Ailanthus, or Tree-of-Heaven, note the glands at the base of each leaflet, shown in the photo at the right. See those greenish bumps at the end of some of the lower leaflet veins? They are glands producing a strong, musky odor. The gland in the picture's bottom, right corner is even glistening with a drop of its musky stuff. I'm not sure what the main purpose of these glands is but I've also seen ants hanging around these trees, so maybe this is another example of a plant with an ant-defense. Or maybe the glands simply stink so much that wandering herbivores just wouldn't want to eat it.
At the left you see the much-magnified underside of a Lemon Basil leaf, Osimum basilicum citriodorum, freshly plucked from my own garden. The dark points are glands which secrete a very fragrant, somewhat bitter substance. Basil is a member of the Mint Family and you can find these kinds of glands on many mint species. In most mints the smelly substance is understood to repel insects and other critters which might eat the plant. However, basil has been cultivated by people for so long that the unpleasant affects of the fragrant oils have been removed, leaving only a pleasant smelling leaf that's great to eat in salads and soups!
Maybe you've heard that St. John's-wort, Hypericum punctatum, is a medicinal herb that will cheer you up -- it's an "antidepressant." I don't know about that, but I do know that the St. John's-wort plant is covered with an abundance of oil glands and black dots that may contain interesting chemicals. The picture at the right shows a much-magnified section of St. John's-wort leaf from a wild plant near my trailer. On it you can see both the black dots and the translucent oil glands. Do the chemicals in these dots and glands not only cause moody people to lighten up but also do something to bugs that keeps them from eating the St. John's-wort's leaves? Maybe...
Here's something that's always interesting to do: Each time you meet a new plant, just sit down and try to figure out how it defends itself from all the animals who want to eat it. Does the odor of its crushed leaves suggest the presence of noxious chemicals? Are there spines, sharp hairs, or hairs mounted with sticky glands? Is there something attracting vicious ants? Or something else we haven't even mentioned?
This line of investigation works better with wild plants than with garden species. That's because during the domestication process a species' natural defenses are often lost. The same bitter chemicals, sharp spines, and tough fibers that repel insects also make the plant less desirable to humans, and horticulturists do what they can do rid their plant of those features. The result is a garden plant that tastes much better than its wild ancestor, but which now needs our help to keep bugs off it.