Polar Contour Plot using bar_polar in Python

I am trying to create an animated, polar contour plot that represents the evolution of fluid flow over time inside of an annular cross-section. I realize that Plotly does not directly support polar contours, but I have seen several suggestions, both on here and on Github, that suggest that you can use bar_polar to get most of the functionality. I’ve been trying that, but have run into one main issue.

Even with polar_bargap = 0, there is still a gap in my bars, and it makes it much harder to read the plot. With a refined grid, the gaps/lines take up more of the plot than the actual contour colors. Is there any way to get rid of this? I’ve tried just about every combination I can think of to suppress the grid and bar gap, but nothing seems to eliminate it. The plot works perfectly aside from this, so if I can figure this out, this will be a viable way of making polar contours for me.

See below for some code that replicates the issue, as well as a picture highlighting it. As you can see all of the white lines mask the colors of the contour, and make it much more difficult to discern the color gradients.

import numpy as np
import plotly.express as px

r, theta = np.mgrid[0.5:1:150j, 0:360:150j]

color = r**2.+theta
fig = px.bar_polar(r=r.ravel(),theta=theta.ravel(),color=color.ravel())
fig.update_layout(polar_bargap=0)
fig.update_polars(hole=0.5)
fig.show()

Hey @UserHandel welcome to the forums.

There is one thing you can do to improve this, if I understand your issue correctly. Try this:

fig.update_traces(dict(marker=dict(line=dict(width=0, color="rgba(255,0,0,0)"))))

Actually it is not necessary to include both, the line_width and line_color as the outcome is the same. There are still some lines visible, might be grid_lines, axis_lines or something like that.

1 Like

Awesome - thank you! The lines still seem to show up with this approach, but they’re far less noticeable, so the graph is much easier to interpret.

1 Like

Wow… Nothing came up in my mind to make marker line transparent or to set marker line width 0.
You are another level man @AIMPED !

1 Like