✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Polar plot sector tick rotation labels, special case

Iinstead of labels that mark 0 to 360 degrees, I’d like to have the labels mark 0 to 180 clockwise and 0 to -180 degrees counter clockwise. If this is not possible as an option, is there an option for custom labels? If so, could someone provide an example?

The use-case is a rotating radar that has a cable that prevents full 360 degree rotation. It can only traverse 180 degrees clockwise or counterclockwise.

thank you.
bob s.


To get ticklabels ranging from -180 to 180 degrees, just update fig.layout as follows:

fig.update_layout(polar_angularaxis= dict(tickvals = [0, 45, 90, 135, 180, 225, 270, 315],
                                          ticktext=['$0^\\circ$',  '$45^\\circ$', '$90^\\circ$', '$135^\\circ$', 
                                                        '$-180^\\circ$', '$-135^\\circ$', '$-90^\\circ$', '$-45^\\circ$'])) 

This makes ticktext[k] to be displayed at the tickval[k], k=0, …

It workswith both barpolar and scatterpolar.

1 Like

thank you !!! :heart: :heart: :heart:

An alternative would be fig.update_polars(sector=[-180,180])


thank you !!! :sunglasses: :sunglasses: :sunglasses: :sunglasses:

It’s so nice using sector, but from this description

 |          Sets angular span of this polar subplot with two angles
 |          (in degrees). Sector are assumed to be spanned in the
 |          counterclockwise direction with 0 corresponding to
 |          rightmost limit of the polar subplot.

I couldn’t deduce the role of sector.

@empet definitely agreed! Do you have a suggestion for how to more clearly document this? This is wrapped in PX with range_theta and there’s a small example here: https://plot.ly/python/polar-chart/#polar-chart-sector

We would absolutely welcome any PRs on these doc pages… just click on the “edit this page in Github” button in the top-right and let us know what would help :slight_smile:

I tried this example, and it worked using fig.update_polars(sector=[-180,180]), but I want clockwise positive, so when I reversed the parameters, fig.update_polars(sector=[180,-180]), the image blew up. Interesting. There’s probably a logical reason for this.

You can flip the direction like this: fig.update_polars(sector=[-180,180], angularaxis=dict(direction="clockwise", rotation=0))

perfect. thank you. I hate the 20 word minimum for replies.

Followup question.

I asked about plotly but I am using dash, because everything in plotly translates to dash but
plotly is simpler to demo.

Now, for dash, if I use 0 rotation I get a 90 degrees rotation
“angularaxis” : {
“rotation” : 0,
“direction” : “clockwise”}

But if f I use 90 for rotation, the dash plot looks like the plotly plot with 0 rotation.

What is going on?