legumbre: is actually a technical term: any member of the "legumes". That includes peas, beans, etc. In Spanish it is not used for peanuts or soy, although they are still "legumes", because the way they are eaten is different from the traditional legumbres.
vegetal: is again a technical term: anything from the "plant" kingdom. It is not used for clasification. However, it is sometimes used as an adjective to some prepared food that contains (not exclusively) more "verduras" or "hortalizas" than expected, such as "bocadillo vegetal", "tortilla vegetal", "lasaña vegetal"...
hortaliza: any food coming from the huerta, that is the "kitchen garden" or vegetable garden. That will include some fruits, such as tomatos or peppers, as well as roots, potatos, etc, but it will not include tree fruits. Some items will be included or not depending on the speaker: melons, pumpkins, berries...
verdura (you didn't ask, but anyway): any hortaliza_ that is more or less green (verde), that is a leaf. Some people may also include items of difficult classifications, but similar uses, such as coliflowers, asparagus, soy shoots, or even onions.
fruta: any fruit except if it is seen as a hortaliza. Also some non-fruits that are consumed as if they were real fruits, such as strawberries or figs.