| 1 | [Bug]: Constrained layout UserWarning even when False |
| 2 | ### Bug summary |
| 3 | |
| 4 | When using layout settings such as `plt.subplots_adjust` or `bbox_inches='tight`, a UserWarning is produced due to incompatibility with constrained_layout, even if constrained_layout = False. This was not the case in previous versions. |
| 5 | |
| 6 | ### Code for reproduction |
| 7 | |
| 8 | ```python |
| 9 | import matplotlib.pyplot as plt |
| 10 | import numpy as np |
| 11 | a = np.linspace(0,2*np.pi,100) |
| 12 | b = np.sin(a) |
| 13 | c = np.cos(a) |
| 14 | fig,ax = plt.subplots(1,2,figsize=(8,2),constrained_layout=False) |
| 15 | ax[0].plot(a,b) |
| 16 | ax[1].plot(a,c) |
| 17 | plt.subplots_adjust(wspace=0) |
| 18 | ``` |
| 19 | |
| 20 | |
| 21 | ### Actual outcome |
| 22 | |
| 23 | The plot works fine but the warning is generated |
| 24 | |
| 25 | `/var/folders/ss/pfgdfm2x7_s4cyw2v0b_t7q80000gn/T/ipykernel_76923/4170965423.py:7: UserWarning: This figure was using a layout engine that is incompatible with subplots_adjust and/or tight_layout; not calling subplots_adjust. |
| 26 | plt.subplots_adjust(wspace=0)` |
| 27 | |
| 28 | ### Expected outcome |
| 29 | |
| 30 | no warning |
| 31 | |
| 32 | ### Additional information |
| 33 | |
| 34 | Warning disappears when constrained_layout=False is removed |
| 35 | |
| 36 | ### Operating system |
| 37 | |
| 38 | OS/X |
| 39 | |
| 40 | ### Matplotlib Version |
| 41 | |
| 42 | 3.6.0 |
| 43 | |
| 44 | ### Matplotlib Backend |
| 45 | |
| 46 | _No response_ |
| 47 | |
| 48 | ### Python version |
| 49 | |
| 50 | _No response_ |
| 51 | |
| 52 | ### Jupyter version |
| 53 | |
| 54 | _No response_ |
| 55 | |
| 56 | ### Installation |
| 57 | |
| 58 | conda |