Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何设置x轴标题和seaborn distplot上的标题_Python_Python 3.x_Seaborn - Fatal编程技术网

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.