Python 如何设置x轴标题和seaborn distplot上的标题
我有一个熊猫数据框,看起来像这样Python 如何设置x轴标题和seaborn distplot上的标题,python,python-3.x,seaborn,Python,Python 3.x,Seaborn,我有一个熊猫数据框,看起来像这样 import pandas as pd dt = pd.DataFrame({'var':[1,1,1,2,2,3,3,3,3,3]}) 我正在创建一个dist图,如下所示: import seaborn as sns fig = sns.distplot(dt['var'], norm_hist=False, kde=False, bins=3).get_figure() 然后我将这个绘图保存为pdf格式 from matplotlib.backends.
import pandas as pd
dt = pd.DataFrame({'var':[1,1,1,2,2,3,3,3,3,3]})
我正在创建一个dist图,如下所示:
import seaborn as sns
fig = sns.distplot(dt['var'], norm_hist=False, kde=False, bins=3).get_figure()
然后我将这个绘图保存为pdf格式
from matplotlib.backends.backend_pdf import PdfPages
pdf = PdfPages('foo.pdf')
pdf.savefig(fig, height=10, width=18, dpi=500, bbox_inches='tight', pad_inches=0.5)
plt.close()
如何更改绘图处的标题和x轴标题?我认为您可以使用
pyplot
尝试:
我想你可以使用
pyplot
尝试:
plt.xlabel("x-axis")
plt.title("title")
import seaborn as sns
import matplotlib.pyplot as plt
fig = sns.distplot(dt['var'], norm_hist=False, kde=False, bins=3).get_figure()
plt.title("something")
plt.xlabel("something")
plt.ylabel("something")
from matplotlib.backends.backend_pdf import PdfPages
pdf = PdfPages('foo.pdf')
pdf.savefig(fig, height=10, width=18, dpi=500, bbox_inches='tight', pad_inches=0.5)
plt.close() #if you want to present on jupyter you need to comment this out.