Both these words seem to mean "worry-free" or optimistic. A quick check on Weblio somehow validates this. How do these words differ in terms of nuance? のんき is also said to mean careless and other things that have a negative connotation in English, but I cannot see sample sentences that support these negative qualities (unlike, say, そそっかしい).
1 Answer
のんき is about temper. A のんきな人 is always calm (often to a fault), slow to start doing something, and rarely gets serious/angry. The antonym is 短気 (short-tempered) or せわしい (restless).
楽観的 is about one's way of thinking. A 楽観的な人 is an optimistic person who believes "It's gonna be okay". The antonym is 悲観的 (pessimistic). You can use 楽観的 to describe your attitude about one specific issue. For example, 私はこの件に関して楽観的です means "I am optimistic about this issue". 楽観的 does not necessarily modify a person/personality. You can say 楽観的な予測 "optimistic estimate", for example.