Hi
I am trying to plot a Barpolar() plot with a colorbar next to it.
Does Barpolar() offer such a feature? - I canāt figure it out from the documentation.
One alternative I found was px.bar_polar().
Thanks a lot for your help,
Martin
Hi
I am trying to plot a Barpolar() plot with a colorbar next to it.
Does Barpolar() offer such a feature? - I canāt figure it out from the documentation.
One alternative I found was px.bar_polar().
Thanks a lot for your help,
Martin
@vont,
Yes, there is a colorbar, but it is a a marker property , used when the marker color is an array of values to be mapped onto a colorscale:
import numpy as np
import plotly.graph_objects as go
r, theta = np.meshgrid(np.linspace(0, 1, 10), np.linspace(0, 360, 18))
fig = go.Figure(go.Barpolar(
r= r.flatten(),
theta=theta.flatten(),
marker_color=(r.flatten())**2-0.2, #marker_color is a function of radius
marker_colorscale="viridis", marker_colorbar_thickness=24,
marker_cmin=0, marker_cmax=1))
fig.update_layout(width=500, height=500)
or marker_color is an array of values independent on r and theta:
theta=np.linspace(0, 360, 18)
r= np.ones(theta.shape)
fig = go.Figure(go.Barpolar(
r= r.flatten(),
theta=theta,
marker_color=np.random.rand(18), ,
marker_colorscale="ice", marker_colorbar_thickness=24,
))
fig.update_layout(width=500, height=500)
Thanks a lot for your help empet! I am still struggling a bit to read the docs but thatās because I am new I guess.
I saw that there was the class plotly.graph_objects.barpolar.Marker and that it has an argument colorbar=None but I didnāt know how to access it when creating the figure with
fig = go.Figure(go.Barpolar(ā¦)
I kept typing a dot instead of an underscore between āmarkerā and its property ācolorbarā.
Something like this āmarker.colorbar.bgcolor = ācrimsonāā instead of āmarker_colorbar_bgcolor = ācrimsonāā.
Thanks so much and have a nice weekend!