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]: ValueError thrown whenlevels is set to a lower value thanvmin when usingcontours method of Axes #26531

Closed
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone
@ymzayek

Description

@ymzayek

Bug summary

With the recent mpl prerelease, we started to have a failure in the test suite of nilearn, a package that depends on matplotlib for visualization. I reproduced the error with a matplotlib example and it seems that when callingAxes.contours it's not possible to set thelevels parameter to values less thanvmin using array-like input. This happens even whenvmax is also set by the user and it seems to be because vmax ends up being set to 0 internally. The code reproduced below will throwValueError: minvalue must be less than or equal to maxvalue. I'm not sure if it's a usage error or a bug so let me know if this is expected behavior, however as I understand it the values forlevels andvmin andvmax should be independent.

Code for reproduction

importmatplotlib.pyplotaspltimportnumpyasnpfeature_x=np.arange(0,50,2)feature_y=np.arange(0,50,3)# Creating 2-D grid of features[X,Y]=np.meshgrid(feature_x,feature_y)fig,ax=plt.subplots(1,1)Z=np.cos(X/2)+np.sin(Y/4)# plots contour linesax.contour(X,Y,Z,levels=[0.0,0.1],vmin=0.2,vmax=0.8)

Actual outcome

ValueErrorTraceback (mostrecentcalllast)[/home/yasmin/.config/Code/User/globalStorage/buenon.scratchpads/scratchpads/47a6066b9dfaca1c2b13ea2e99f4e929/scratch.py](https://file+.vscode-resource.vscode-cdn.net/home/yasmin/.config/Code/User/globalStorage/buenon.scratchpads/scratchpads/47a6066b9dfaca1c2b13ea2e99f4e929/scratch.py)in ()     [109](file:///home/yasmin/.config/Code/User/globalStorage/buenon.scratchpads/scratchpads/47a6066b9dfaca1c2b13ea2e99f4e929/scratch.py?line=108)Z=np.cos(X [/](https://file+.vscode-resource.vscode-cdn.net/)2)+np.sin(Y [/](https://file+.vscode-resource.vscode-cdn.net/)4)     [111](file:///home/yasmin/.config/Code/User/globalStorage/buenon.scratchpads/scratchpads/47a6066b9dfaca1c2b13ea2e99f4e929/scratch.py?line=110)# plots contour lines---> [112](file:///home/yasmin/.config/Code/User/globalStorage/buenon.scratchpads/scratchpads/47a6066b9dfaca1c2b13ea2e99f4e929/scratch.py?line=111)ax.contour(X,Y,Z,levels=[0.0,0.1],vmin=0.2,vmax=0.8)File [~/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py:1465](https://file+.vscode-resource.vscode-cdn.net/home/yasmin/nilearn/nilearn/~/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py:1465),in_preprocess_data..inner(ax,data,*args,**kwargs)   [1462](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py?line=1461) @functools.wraps(func)   [1463](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py?line=1462)definner(ax,*args,data=None,**kwargs):   [1464](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py?line=1463)ifdataisNone:-> [1465](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py?line=1464)returnfunc(ax,*map(sanitize_sequence,args),**kwargs)   [1467](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py?line=1466)bound=new_sig.bind(ax,*args,**kwargs)   [1468](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py?line=1467)auto_label= (bound.arguments.get(label_namer)   [1469](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/__init__.py?line=1468)orbound.kwargs.get(label_namer))File [~/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py:6498](https://file+.vscode-resource.vscode-cdn.net/home/yasmin/nilearn/nilearn/~/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py:6498),inAxes.contour(self,*args,**kwargs)   [6489](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py?line=6488)"""   [6490](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py?line=6489) Plot contour lines.   [6491](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py?line=6490)   (...)   [6495](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py?line=6494) %(contour_doc)s   [6496](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py?line=6495) """   [6497](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py?line=6496)kwargs['filled']=False-> [6498](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/axes/_axes.py?line=6497)contours=mcontour.QuadContourSet(self,*args,**kwargs)...-> [1361](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/colors.py?line=1360)raiseValueError("minvalue must be less than or equal to maxvalue")   [1362](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/colors.py?line=1361)else:   [1363](file:///home/yasmin/miniconda3/envs/nilearn-dev/lib/python3.10/site-packages/matplotlib/colors.py?line=1362)ifclip:ValueError:minvaluemustbelessthanorequaltomaxvalue

Expected outcome

A plot matplotlib.contour.QuadContourSet object

Additional information

The test that led to this failure did pass before this version

Operating system

Ubuntu 22.04

Matplotlib Version

3.8.0rc1

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.10.4

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp