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]: Slider #25771

Open
Open
@pdalet

Description

@pdalet

Bug summary

I have found a bug with the slider object (matplotlib 3.7.1)

The script is joined.
It works very well with win 10 and ubuntu 22.04 and python3.11.2
It doesn't work with with win 10 and ubuntu 22.04 and python3.11.3

When I click on the slider, I have this message

ax is None
I suppose a bug from python 3.11.3 or matplotlib !!

Thanks a lot

Philippe DALET
Lyp Champollion
FIGEAC - FRANCE

Code for reproduction

#!/usr/local/bin/python3.11# -*- coding: utf-8 -*-# Philippe DALET# Lyp Champollion-46100 FIGEAC# 22 october 2022# 20 april 2023importmatplotlib.pyplotaspltfrommatplotlib.widgetsimportSliderimportmatplotlib.animationasanimationfrommathimportpiimportnumpyasnpxmax=10Nmax=1000lamb=3.0#constantsxA=1xB=2#t=0T=2v=lamb/Tdt=T/50Amplitude=1#datasx=np.linspace(0,xmax,Nmax)t=np.linspace(0,2*T,Nmax)#cameray=np.cos(2*pi*(t/T-x/lamb) )#oscillogramyA_t=Amplitude*np.cos(2*pi*(t/T-xA/lamb) )yB_t=Amplitude*np.cos(2*pi*(t/T-xB/lamb) )#plotfig,a=plt.subplots(2)plt.subplots_adjust(left=0.10,bottom=0.25)fig.suptitle(r'$Onde\ progressive\ sinusoidale$',color='b',fontsize=20)#cameraa[0].set_xlim(0,xmax)a[0].set_xticks(np.arange(0,10,step=0.5))a[0].set_ylim(-1.5*Amplitude,+1.5*Amplitude)a[0].grid(True)a[0].set_xlabel('x (m)',fontsize=10)a[0].set_ylabel(r'$y(x,t)$',rotation=0,fontsize=10)a[0].text(8.5,1.2,r'$\lambda=%dm\ et\ T=%ds$'%(lamb,T) ,fontsize=12)#oscillogramm yA yBa[1].set_xlim(0,2*T)a[1].set_ylim(-1.5*Amplitude,+1.5*Amplitude)a[1].grid(True)a[1].set_xlabel('t (s)',fontsize=10)a[1].set_ylabel(r'$y(t)$',rotation=0,fontsize=10)a[1].plot(t,yA_t,'b',label=r'$y_{xA}(t)$')a[1].plot(t,yB_t,'g',label=r'$y_{xB}(t)$')a[1].legend(loc=1)line,=a[0].plot(x,y,'r')definit():line.set_ydata(np.ma.array(x,mask=True))scatA=a[0].scatter(xA,0 ,c='b')scatB=a[0].scatter(xB,0 ,c='g')lineA=a[0].vlines(xA,-1.5*Amplitude,+1.5*Amplitude,colors='b')lineB=a[0].vlines(xB,-1.5*Amplitude,+1.5*Amplitude,colors='g')returnline,scatA,scatB,lineA,lineBdefanimate(i):globalx,y,t,linet=i*dty=Amplitude*np.cos(2*pi*(t/T-x/lamb) )yA=y[int(xA*100)]yB=y[int(xB*100)]line.set_ydata(y)scatA=a[0].scatter(xA,yA ,c='b')scatB=a[0].scatter(xB,yB ,c='g')lineA=a[0].vlines(xA,-1.5*Amplitude,+1.5*Amplitude,colors='b')lineB=a[0].vlines(xB,-1.5*Amplitude,+1.5*Amplitude,colors='g')returnline,scatA,scatB,lineA,lineBdefplot():#oscillogramma[1].clear()a[1].grid(True)a[1].set_xlim(0,2*T)a[1].set_ylim(-1.5*Amplitude,+1.5*Amplitude)a[1].set_xlabel('t (s)',fontsize=10)a[1].set_ylabel(r'$y(t)$',rotation=0,fontsize=10)t=np.linspace(0,2*T,Nmax)yA_t=Amplitude*np.cos(2*pi*(t/T-xA/lamb) )yB_t=Amplitude*np.cos(2*pi*(t/T-xB/lamb) )a[1].plot(t,yA_t,'b',label=r'$y_{xA}(t)$')a[1].plot(t,yB_t,'g',label=r'$y_{xB}(t)$')a[1].legend(loc=1)#cameraa[0].clear()a[0].grid(True)a[0].set_xlim(0,xmax)a[0].set_xlabel('x (m)',fontsize=10)a[0].set_ylabel(r'$y(x,t)$',rotation=0,fontsize=10)a[0].set_xticks(np.arange(0,10,step=0.5))a[0].set_ylim(-1.5*Amplitude,+1.5*Amplitude)fig.canvas.draw_idle()defupdateA(val):globalxAxA=valplot()defupdateB(val):globalxBxB=valplot()# horizontal slider to control xAaxA=plt.axes([0.10,0.15,0.80,0.03],facecolor='lightgoldenrodyellow')xA_slider=Slider(ax=axA,label='xA',valmin=0,valmax=xmax,valinit=xA,color='blue')xA_slider.on_changed(updateA)# horizontal slider to control xBaxB=plt.axes([0.10,0.10,0.80,0.03],facecolor='lightgoldenrodyellow')xB_slider=Slider(ax=axB,label='xB',valmin=0,valmax=xmax,valinit=xB,color='green')xB_slider.on_changed(updateB)ani=animation.FuncAnimation(fig,animate,init_func=init,frames=100 ,interval=25,blit=True)figManager=plt.get_current_fig_manager()#figManager.window.showMaximized() # QtAgg onlyplt.show()

Actual outcome

Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 1226, in _on_timer
ret = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/matplotlib/animation.py", line 1426, in _step
still_going = super()._step(*args)
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/matplotlib/animation.py", line 1119, in _step
self._draw_next_frame(framedata, self._blit)
File "/usr/local/lib/python3.11/site-packages/matplotlib/animation.py", line 1139, in _draw_next_frame
self._post_draw(framedata, blit)
File "/usr/local/lib/python3.11/site-packages/matplotlib/animation.py", line 1162, in _post_draw
self._blit_draw(self._drawn_artists)
File "/usr/local/lib/python3.11/site-packages/matplotlib/animation.py", line 1177, in _blit_draw
cur_view = ax._get_view()
^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute '_get_view'
Aborted (core dumped)

Expected outcome

crash

Additional information

No response

Operating system

windows 10 , Ubuntu 22.04

Matplotlib Version

3.7.1

Matplotlib Backend

QtAgg

Python version

3.11.3

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