Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: rorigin gives weird results when used with rscale('log') and rorigin behavior is unintuitive #30177

Closed as not planned
@tillboehringer

Description

@tillboehringer

Bug summary

When trying to set rorigin of a polar plot with logscale on the radial direction, it just results in something strange. I think the reason this happens is because rorigin is connected to the values on the r-axis, which in itself, to me is not clear why it is this way.

For example if I want to to multiple plots of different measured values, I want all the plots to look the same despite different magnitudes of the different measurements. The values themselves shouldn't change the layout of the plot. For me, it would make way more sense if rorigin would behave with a relative value between 0 and 1. 0 means the origin is in the center, 1 means the origin would be on the outer radius.

Or is the problem that I don't understand how to use rorigin, the documentation is not clear here.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

angles = np.radians(np.linspace(15, 145, 10))
r = np.logspace(3, 9, len(angles))

fig = plt.figure()
ax = plt.axes(projection='polar')

ax.scatter(angles, r)

ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
ax.set_rscale('log')
ax.set_thetamin(15)
ax.set_thetamax(145)

ax.set_rorigin(-10**9)

Actual outcome

Image

Expected outcome

Image

Just with the log scale.

Edit: Plotly does this with the hole command. The hole command works as with a value between 0 and 1.

Image

import plotly.express as px
import plotly

# Sample data (replace with your actual data)
theta = np.rad2deg(angles)
r = np.exp(np.linspace(0, 5, len(theta))) # Example: exponential values for the radius

# Create the polar scatter plot with a logarithmic radial axis
fig = px.scatter_polar(r=r, theta=theta, log_r=True)

offset = 70

# Optionally, customize the plot (e.g., add a title, change the start angle)
fig.update_layout(
    title="Radial Log Plot",
    # polar_radialaxis_angle=90,
    # polar_angularaxis_rotation=90, # Rotate the angular axis labels 90 degrees
    polar = dict(sector = [15-offset,145-offset])
)

fig.update_polars(hole=0.3)

fig.show()

Additional information

No response

Operating system

OS/X

Matplotlib Version

3.10.3

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.13.2

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions