Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.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 如何在seaborn barplot中添加更多栅格?_Python_Matplotlib_Plot_Seaborn - Fatal编程技术网

Python 如何在seaborn barplot中添加更多栅格?

Python 如何在seaborn barplot中添加更多栅格?,python,matplotlib,plot,seaborn,Python,Matplotlib,Plot,Seaborn,如何将nunique(x轴)划分为更小的网格?您可以使用matplotlib中的ticker,因此,它可以: 类matplotlib.ticker.MultipleLocator(base=1.0) 在视图中每个基准的整数倍上设置一个勾号 间隔时间 我们需要将绘图指定给Axis类,并按如下方式进行修改: df.columns = ['feature','nunique'] sns.set(rc={'figure.figsize':(10,8)}) ax = sns.barplot(y='fea


如何将nunique(x轴)划分为更小的网格?

您可以使用matplotlib中的ticker,因此,它可以:

类matplotlib.ticker.MultipleLocator(base=1.0)

在视图中每个基准的整数倍上设置一个勾号 间隔时间

我们需要将绘图指定给Axis类,并按如下方式进行修改:

df.columns = ['feature','nunique']

sns.set(rc={'figure.figsize':(10,8)})
ax = sns.barplot(y='feature', x='nunique', data=df, orient = 'h')

您可以使用matplotlib中的ticker,因此,它可以:

类matplotlib.ticker.MultipleLocator(base=1.0)

在视图中每个基准的整数倍上设置一个勾号 间隔时间

我们需要将绘图指定给Axis类,并按如下方式进行修改:

df.columns = ['feature','nunique']

sns.set(rc={'figure.figsize':(10,8)})
ax = sns.barplot(y='feature', x='nunique', data=df, orient = 'h')

标记更改为包含要显示在x轴上的数字的数组

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.ticker as ticker
import numpy as np

sns.set()
tips = sns.load_dataset("tips")
fig, ax = plt.subplots(1, 2,figsize=(10,4))

sns.barplot(x="total_bill",y="day",data=tips,ax=ax[0],ci=None)
ax[0].xaxis.set_major_locator(ticker.MultipleLocator(2.5))

sns.barplot(x="total_bill",y="day",data=tips,ax=ax[1],ci=None)
ax[1].xaxis.set_major_locator(ticker.MultipleLocator(1))

将您的刻度更改为包含要显示在x轴上的数字的数组

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.ticker as ticker
import numpy as np

sns.set()
tips = sns.load_dataset("tips")
fig, ax = plt.subplots(1, 2,figsize=(10,4))

sns.barplot(x="total_bill",y="day",data=tips,ax=ax[0],ci=None)
ax[0].xaxis.set_major_locator(ticker.MultipleLocator(2.5))

sns.barplot(x="total_bill",y="day",data=tips,ax=ax[1],ci=None)
ax[1].xaxis.set_major_locator(ticker.MultipleLocator(1))