Scala日記

Scalaの備忘録。ときどき研究の話。

Matplotlib (with seaborn) で出力するPDFの下のほうが切れてしまうときは bbox_inches='tight'

Scalaとは関係ないですが…。探すのに苦労したので。 結局は学生さんに教えてもらいました。

import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt

data = ['some data points']
df = pd.DataFrame(data=data, columns=['model', 'score'])

sns.set_context("talk",1, {"lines.linewidth": 1})
plt.xticks(rotation=60)
plot = sns.boxplot(x="model", y="score", data=df)
plt.xlabel(' ')
plt.figure(figsize=(6, 5), dpi=300)
plot.figure.savefig('sample.pdf', bbox_inches='tight')