当前位置:   article > 正文

Python 数据分析画图_python数据分析加画图的训练目的

python数据分析加画图的训练目的

Python 数据分析画图&one-hot编码

标签(空格分隔): python


Matplotlib画图

fig, axes = plt.subplots(2, 2) #axes是一个数组
  • 1
fig = plt.figure()
fig.set(alpha=0.2) 

#把图分为2行3列,当前在(0,0)位置画图
plt.subplot2grid((2, 3), (0, 0))

#data_train是DataFrame数据类型 bar表示柱形图
data_train.Survived.value_counts().plot(kind='bar')

plt.plot(randn(30).cumsum(), 'ko--') #k表示颜色,o表示标记强调数据点,--表示线条类型
plt.plot(randn(30).cumsum(), color='k', linestyle='dashed', marker='o') #和上面等价
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

设置轴标签 刻度

  • xlim控制图标的范围,plt.xlim()返回当前X轴范围,plt.xlim([0, 10]).我们也可以用过subplot的实例ax,如ax.get_xlim和ax.set_xlim来获取设置
  • set_xticks控制刻度位置
  • set_xticklabels控制刻度上面的标签
    实例
fig = plt.figure()
ax = fig.add_subplot(2, 2, 1)
ax.plot(np.random.randn(1000).cumsum(), 'ko--')
ticks = ax.set_xticks([0, 250, 500, 750, 1000])
labels = ax.set_xticklabels(['one', 'two', 'three', 'four', 'five'], rotation=3, fontsize='small')
ax.set_title('My Title')
ax.set_xlabel('xlabel')

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

<

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/963859
推荐阅读
相关标签
  

闽ICP备14008679号