Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.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 海生调整标记_Python_Seaborn - Fatal编程技术网

Python 海生调整标记

Python 海生调整标记,python,seaborn,Python,Seaborn,正如您在这里看到的,这里的X轴标签非常不可读。无论我如何调整体形大小,都会发生这种情况。我正试图找出如何调整标签,使其只显示某些点。X轴都是在-1到1之间的数字,我认为在-1、.5、0、.5和1之间有标签会更好,也更便于观看 有办法做到这一点吗?谢谢大家! 这是我的密码 sns.set(rc={'figure.figsize':(20,8)}) ax = sns.countplot(musi['Positivity']) ax.set_xticklabels(ax.get_xticklabels

正如您在这里看到的,这里的X轴标签非常不可读。无论我如何调整体形大小,都会发生这种情况。我正试图找出如何调整标签,使其只显示某些点。X轴都是在-1到1之间的数字,我认为在-1、.5、0、.5和1之间有标签会更好,也更便于观看

有办法做到这一点吗?谢谢大家!

这是我的密码

sns.set(rc={'figure.figsize':(20,8)})
ax = sns.countplot(musi['Positivity'])
ax.set_xticklabels(ax.get_xticklabels(), rotation=40, ha='right')
plt.tight_layout()
plt.show()

基本上,
seaborn
matplotlib
上的包装器。您可以使用
matplotlib ticker
功能执行作业。请参考下面的示例

让我们每隔
1
间距绘制勾号

导入matplotlib.pyplot作为plt
将matplotlib.ticker导入为ticker
导入seaborn作为sns
sns.set_主题(style=“whitegrid”)
x=[0,5,9,10,15]
y=[0,1,2,3,4]
勾选间距=1
图,ax=plt子批次(1,1)
sns.线形图(x,y)
ax.xaxis.set_major_locator(滴答器多路指示器(滴答间距))
plt.show()

现在,让我们每隔
5个
ticks绘制一个ticks

导入matplotlib.pyplot作为plt
将matplotlib.ticker导入为ticker
导入seaborn作为sns
sns.set_主题(style=“whitegrid”)
x=[0,5,9,10,15]
y=[0,1,2,3,4]
勾选间距=5
图,ax=plt子批次(1,1)
sns.线形图(x,y)
ax.xaxis.set_major_locator(滴答器多路指示器(滴答间距))
plt.show()


p.S.:此解决方案通过提供给ticker.multipleLocate()的数字为您显式控制勾号间距,允许自动确定限制,并且便于以后阅读。

嘿,非常感谢!