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

Polar log scale: fix inner patch boundary and spine location#30223

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
rcomer wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromrcomer:polar-log-spine
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
8 changes: 7 additions & 1 deletionlib/matplotlib/projections/polar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -817,6 +817,10 @@ def _init_axis(self):
self.xaxis=ThetaAxis(self,clear=False)
self.yaxis=RadialAxis(self,clear=False)
self.spines['polar'].register_axis(self.yaxis)
inner_spine=self.spines.get('inner',None)
ifinner_spineisnotNone:
# Subclasses may not have inner spine.
inner_spine.register_axis(self.yaxis)

def_set_lim_and_transforms(self):
# A view limit where the minimum radius can be locked if the user
Expand DownExpand Up@@ -961,7 +965,9 @@ def draw(self, renderer):
thetamin,thetamax=np.rad2deg(self._realViewLim.intervalx)
ifthetamin>thetamax:
thetamin,thetamax=thetamax,thetamin
rmin,rmax= ((self._realViewLim.intervaly-self.get_rorigin())*
rscale_tr=self.yaxis.get_transform()
rmin,rmax= ((rscale_tr.transform(self._realViewLim.intervaly)-
rscale_tr.transform(self.get_rorigin()))*
self.get_rsign())
ifisinstance(self.patch,mpatches.Wedge):
# Backwards-compatibility: Any subclassed Axes might override the
Expand Down
5 changes: 4 additions & 1 deletionlib/matplotlib/spines.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -265,11 +265,14 @@ def _adjust_location(self):
self._path=mpath.Path.arc(np.rad2deg(low),np.rad2deg(high))

ifself.spine_type=='bottom':
rmin,rmax=self.axes.viewLim.intervaly
tr=self.axis.get_transform()
rmin,rmax=tr.transform(self.axes.viewLim.intervaly)
try:
rorigin=self.axes.get_rorigin()
exceptAttributeError:
rorigin=rmin
else:
rorigin=tr.transform(rorigin)
scaled_diameter= (rmin-rorigin)/ (rmax-rorigin)
self._height=scaled_diameter
self._width=scaled_diameter
Expand Down
20 changes: 20 additions & 0 deletionslib/matplotlib/tests/test_polar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -482,6 +482,26 @@ def test_polar_log():
ax.plot(np.linspace(0,2*np.pi,n),np.logspace(0,2,n))


@check_figures_equal()
deftest_polar_log_rorigin(fig_ref,fig_test):
# Test that equivalent linear and log radial settings give the same axes patch
# and spines.
ax_ref=fig_ref.add_subplot(projection='polar',facecolor='red')
ax_ref.set_rlim(0,2)
ax_ref.set_rorigin(-3)
ax_ref.set_rticks(np.linspace(0,2,5))

ax_test=fig_test.add_subplot(projection='polar',facecolor='red')
ax_test.set_rscale('log')
ax_test.set_rlim(1,100)
ax_test.set_rorigin(10**-3)
ax_test.set_rticks(np.logspace(0,2,5))

foraxinax_ref,ax_test:
# Radial tick labels should be the only difference, so turn them off.
ax.tick_params(labelleft=False)


deftest_polar_neg_theta_lims():
fig=plt.figure()
ax=fig.add_subplot(projection='polar')
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp