How to add a completely customized legend to a bubble chart

I want to add a completely customized legend to a bubble chart. How to do this?

This legend includes a bar with a color gradient and several circles from small to large. Thanks.

Legends are not particularly easy to customize. They are always related to the data so you’ll have to prepare your traces accordingly.

Your question is quite generic, if you added some example code / graph it would be easier to help you.

Thank you so much for your reply.

This is the bubble plot I am currently drawing:
WeChat Screenshot_20240215142911

I want to change the legend to a custom legend. As shown in the picture below, there is a gradient bar and several circles of different sizes:

I’m not sure if this is possible in plotly. A while ago I tried some similar stuff: