Skip to content

'bottom cannot be >= top' when using tight_layout #5456

Closed
@blaiseli

Description

@blaiseli

I'm trying to understand why sometimes I get a ValueError when using tight_layout.

The code of matplotlib is too complicated for me, but I'm trying to see what's happening using pdb.

It seems that the problem comes from what get_tight_layout_figure returns:

(Pdb) l
379                                              subplot_list=subplot_list,
380                                              ax_bbox_list=ax_bbox_list,
381                                              pad=pad, h_pad=h_pad, w_pad=w_pad,
382                                              rect=(left, bottom, right, top))
383  
384  ->     return kwargs
(Pdb) p kwargs
{'top': 0.43099934895833336, 'right': 0.97750000000000004, 'bottom': 0.56900065104166675, 'left': 0.16939941406250003}

I guess this in turns comes from what happens in auto_adjust_subplotpars, in the output of _get_bottom and _get_top:

(Pdb) p ax_bbox.ymin
0.3716666666666667
(Pdb) p tight_bbox.ymin
-0.16733398437499999
(Pdb) p ax_bbox.ymin - tight_bbox.ymin
0.53900065104166672
(Pdb) p tight_bbox.ymax
1.1673339843749999
(Pdb) p ax_bbox.ymax
0.6283333333333333
(Pdb) p tight_bbox.ymax - ax_bbox.ymax
0.53900065104166661

I don't know what ax_bbox and tight_bbox exactly are.

I just guess the algorithm to determine the figure properties do not play well with the data I want to plot. Can this be considered a bug ?

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