Exploring the analogy between atoms and optical nanoresonators