Extract Colro Bar

Is there any way to have a figure of only the color bar of a full drawn contour plot?
Edit: Is there any way to get or set min/max value on color bar? That may solve my problem as well.

I extract Plotly contour with fig.to_image to show on Folium map as image overlay. Which is working great.
Issue is, I want to show color bar as a sticky image and it requires me to have a separate image of only color scale.
I have tried cropping the color bar from full contour plot, but since the output pixel size will be different for different plots, crop points varies and can not be predetermined.
Also since the each color bar have different numbers on it, I can not show a generic color bar.

This simple issue has become really frustrating, I would appreciate any suggestion on how to achieve this.

Yes, you can set the min/max on a colorbar: https://plotly.com/python/colorscales/

If you’re using px you can use range_color otherwise it’s cmin/cmax or zmin/zmax depending on the trace. If it’s a contour trace it’ll be zmin/zmax.