Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: Inner circle rendering with log-scale + rorigin in polar plots (Fixes #30179)#30185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
bharshavardhanreddy924 wants to merge4 commits intomatplotlib:main
base:main
Choose a base branch
Loading
frombharshavardhanreddy924:fix-polar-log-rorigin
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletionslib/matplotlib/projections/polar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1175,15 +1175,21 @@
returnself.viewLim.ymin

defset_rorigin(self,rorigin):
"""
Update the radial origin.
Parameters
----------
rorigin : float
"""
self._originViewLim.locked_y0=rorigin

# Fix: Adjust tick/grid when using log scale
self._rorigin=rorigin# store internally for use elsewhere
ifhasattr(self,'yaxis'):
ifself.yaxis.get_scale()=='log':
locator=self.yaxis.get_major_locator()
iflocatorisnotNone:
locs=locator.tick_values(self.get_rmin(),self.get_rmax())
# Offset tick locations based on origin, only if loc > 0 (log scale)
adjusted_locs= [abs(rorigin)+locforlocinlocsifloc>0]
self.yaxis.set_ticks(adjusted_locs)

Check warning on line 1189 in lib/matplotlib/projections/polar.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/projections/polar.py#L1188-L1189

Added lines #L1188 - L1189 were not covered by tests
returnself


defget_rorigin(self):
"""
Returns
Expand Down
20 changes: 20 additions & 0 deletionslib/matplotlib/tests/test_axes/test_polar_log_rorigin.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
importnumpyasnp
importmatplotlib.pyplotasplt

Check failure on line 2 in lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶`matplotlib.pyplot` imported but unusedRaw Output:message:"`matplotlib.pyplot` imported but unused" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py" range:{start:{line:2 column:29} end:{line:2 column:32}}} source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"F401" url:"https://docs.astral.sh/ruff/rules/unused-import"} suggestions:{range:{start:{line:2 column:1} end:{line:3 column:1}}}
frommatplotlib.testing.decoratorsimportcheck_figures_equal

@check_figures_equal()

Check failure on line 5 in lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Expected 2 blank lines, found 1Raw Output:message:"Expected 2 blank lines, found 1" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py" range:{start:{line:5 column:1} end:{line:5 column:2}}} source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E302" url:"https://docs.astral.sh/ruff/rules/blank-lines-top-level"} suggestions:{range:{start:{line:4 column:1} end:{line:5 column:1}} text:"\n\n"}
deftest_polar_log_rorigin_rendering(fig_test,fig_ref):
r=np.logspace(-1,1,500)
theta=np.linspace(0,2*np.pi,500)

# Reference (correct rendering after fix)
ax_ref=fig_ref.add_subplot(1,1,1,projection='polar')
ax_ref.set_rscale('log')
ax_ref.set_rorigin(-0.5)
ax_ref.plot(theta,r)

Check warning on line 14 in lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py#L14

Added line #L14 was not covered by tests

# Test output (same code, expected to match)
ax_test=fig_test.add_subplot(1,1,1,projection='polar')
ax_test.set_rscale('log')
ax_test.set_rorigin(-0.5)
ax_test.plot(theta,r)

Check warning on line 20 in lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/tests/test_axes/test_polar_log_rorigin.py#L17-L20

Added lines #L17 - L20 were not covered by tests
Loading

[8]ページ先頭

©2009-2025 Movatter.jp