Kotlin 相比 Java 好在哪里
Kotlin真的值得学习吗
python怎么用matplotlib画柱状图
Python——使用matplotlib绘制柱状图
1、基本柱状图
首先要安装matplotlib 可以使用pip命令直接安装
[python] view plain copy
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list)
plt.show()
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list,fc=’r’)
plt.show()
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list,color=’rgb’)
plt.show()
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
name_list = [’Monday’,’Tuesday’,’Friday’,’Sunday’]
num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list,color=’rgb’,tick_label=name_list)
plt.show()
2、设置颜色
[python] view plain copy
[cpp] view plain copy
3、设置标签
[python] view plain copy
4、堆叠柱状图