Poetry works through imaginative premises and their emotional impact; a listener may recognize a metaphor as figurative. Sophistry makes an unsound proposition pass for reliable evidence or an obvious truth.
“Hope is the sun” can be poetry when offered as metaphor. If someone then claims it proves that hope has the physical temperature of the sun, figurative predication has been illicitly used as a literal premise.
The difference lies in the intended status of the statement; not every effective nonliteral image is sophistry.