Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Subplot title does not obey padding #21394

Closed
@cipriantrofin

Description

@cipriantrofin

Bug summary

Last subplot title does not obey padding.

Code for reproduction

import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({ "Austria" : [1,2,3,4,5],
                    "Belgium" : [6,7,8,9,10],
                    "France" : [11,12,13,14,15] },
                   index = pd.to_datetime(['2000-01-01', '2000-01-02', '2000-01-03', '2000-01-04', '2000-01-05']))

countryList = df.columns

fig, axs = plt.subplots(len(countryList), 1, figsize = (15, len(countryList) * 5), sharex = True)

for i, c in enumerate(countryList):
    axs[i].bar(df.index, df[c])
    axs[i].set_title(c, pad=-14)

Actual outcome

subplots

Expected outcome

"France" subplot title should be aligned as the previous ones.

Operating system

Windows 10 x64

Matplotlib Version

3.4.3

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

Python 3.8.5

Jupyter version

jupyter notebook v6.4.5

Other libraries

No response

Installation

pip

Conda channel

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions