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

[Bug]: Inward direction of ticks works on 2d, but not 3d projections #21729

Open
@ghost

Description

Bug summary

for 2D:

plt.tick_params(axis='x', which='major', direction='in')
plt.tick_params(axis='y', which='major', direction='in')

this works. While on 3D projections:

ax.tick_params(axis='x', which='major', direction='in')
ax.tick_params(axis='y', which='major', direction='in')
ax.tick_params(axis='z', which='major', direction='in')

it is ignored.

Code for reproduction

importnumpyasnpimportmatplotlib.pyplotaspltimportmathN=100000y=np.random.rand(N)s1=0.5y1=y+np.random.normal(0.0,s1,(N))s2=0.8y2=y+np.random.normal(0.0,s2,(N))alphaOpti1=s2*s2/ (s1*s1+s2*s2)alphaOpti2=s1*s1/ (s1*s1+s2*s2)sOpti=math.sqrt(s1*s1*s2*s2/(s1*s1+s2*s2))print('Computed',alphaOpti1,alphaOpti2,sOpti)a1= []a2= []s= []sO= []foralphainrange(101):alphaX=alpha/100.0yy=alphaX*y1+ (1.0-alphaX)*y2a1.append(alphaX)a2.append(1.0-alphaX)s.append(math.sqrt(np.sum((yy-y)**2)/(N-1.0)))sO.append(sOpti)pos=np.argmin(s)print('Simulated',a1[pos],a2[pos],s[pos])plt.figure(figsize=(10,10))plt.plot(a1,s,'r')plt.plot(a1,sO,'g')plt.plot([alphaOpti1],[sOpti],'bo')plt.xlabel(r"$\alpha$")plt.ylabel(r"$\sigma_B^2$")plt.tick_params(axis='x',which='major',direction='in')plt.tick_params(axis='y',which='major',direction='in')plt.grid()plt.show()importnumpyasnpimportmatplotlib.pyplotaspltimportmathN=100000y=np.random.rand(N)s1=0.65y1=y+np.random.normal(0.0,s1,(N))s2=0.8y2=y+np.random.normal(0.0,s2,(N))s3=1.1y3=y+np.random.normal(0.0,s3,(N))alphaOpti1=s2*s2*s3*s3/ (s1*s1*s2*s2+s1*s1*s3*s3+s3*s3*s2*s2)alphaOpti2=s1*s1*s3*s3/ (s1*s1*s2*s2+s1*s1*s3*s3+s3*s3*s2*s2)alphaOpti3=s1*s1*s2*s2/ (s1*s1*s2*s2+s1*s1*s3*s3+s3*s3*s2*s2)sOpti=math.sqrt(s1*s1*s2*s2*s3*s3/(s1*s1*s2*s2+s1*s1*s3*s3+s3*s3*s2*s2))print('Computed:',alphaOpti1,alphaOpti2,alphaOpti3,sOpti)a1= []a2= []a3= []s= []sO= []foralpha1inrange(101):alpha1X=alpha1/100.0foralpha2inrange(101):alpha2X=alpha2/100.0alpha3X=1.0-alpha1X-alpha2Xifalpha3X>=0:yy=alpha1X*y1+alpha2X*y2+alpha3X*y3a1.append(alpha1X)a2.append(alpha2X)a3.append(alpha3X)s.append(math.sqrt(np.sum((yy-y)**2)/(N-1.0)))sO.append(sOpti)fig=plt.figure(figsize=(10,10))ax=fig.add_subplot(111,projection='3d')pos=np.argmin(s)print('Simulated:',a1[pos],a2[pos],a3[pos],s[pos])ax.scatter(a1,a2,s,c='r',alpha=0.1)ax.scatter(a1,a2,sO,c='g',alpha=0.1)ax.scatter([alphaOpti1],[alphaOpti2],[sOpti],c='b')ax.set_xlabel(r"$\alpha_1$")ax.set_ylabel(r"$\alpha_2$")ax.set_zlabel(r"$\sigma_B^2$")ax.tick_params(axis='x',which='major',direction='in')ax.tick_params(axis='y',which='major',direction='in')ax.tick_params(axis='z',which='major',direction='in')ax.w_xaxis.set_pane_color((1.0,1.0,1.0,1.0))ax.w_yaxis.set_pane_color((1.0,1.0,1.0,1.0))ax.w_zaxis.set_pane_color((1.0,1.0,1.0,1.0))plt.show()

Actual outcome

for 2d ticks are only in, while for 3d ticks are going out as well (command ax.tick_params(axis='z', which='major', direction='in') is ignored for x, y, z)

Expected outcome

ticks only going in.

Additional information

No response

Operating system

Feren OS

Matplotlib Version

3.5.0

Matplotlib Backend

QtAgg

Python version

Python 3.8.10

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp