reference other engineer's code to explain wheather linux terminal can display matplotlib' figure
2016-09-23 01:01
417 查看
柱状图(plt.bar)
代码与注释import numpy as np from matplotlib import pyplot as plt plt.figure(figsize=(9,6)) n = 8 X = np.arange(n)+1 #X是1,2,3,4,5,6,7,8,柱的个数 # numpy.random.uniform(low=0.0, high=1.0, size=None), normal #uniform均匀分布的随机数,normal是正态分布的随机数,0.5-1均匀分布的数,一共有n个 Y1 = np.random.uniform(0.5,1.0,n) Y2 = np.random.uniform(0.5,1.0,n) plt.bar(X,Y1,width = 0.35,facecolor = 'lightskyblue',edgecolor = 'white') #width:柱的宽度 plt.bar(X+0.35,Y2,width = 0.35,facecolor = 'yellowgreen',edgecolor = 'white') #水平柱状图plt.barh,属性中宽度width变成了高度height #打两组数据时用+ #facecolor柱状图里填充的颜色 #edgecolor是边框的颜色 #想把一组数据打到下边,在数据前使用负号 #plt.bar(X, -Y2, width=width, facecolor='#ff9999', edgecolor='white') #给图加text for x,y in zip(X,Y1): plt.text(x+0.3, y+0.05, '%.2f' % y, ha='center', va= 'bottom') for x,y in zip(X,Y2): plt.text(x+0.6, y+0.05, '%.2f' % y, ha='center', va= 'bottom') plt.ylim(0,+1.25) plt.show()
相关文章推荐
- linux下画图:modify matplotlib so that we can draw picture under linux
- 在使用matplotlib时报错_tkinter.TclError: couldn't connect to display ":0.0"
- Linux matplotlib 库安装 * The following required packages can not be built: * freetype, png
- Ubuntu11.20 32位linux下编译cppunit报 libcppunit.so: undefined reference to `dlsym'错误问题
- linux下安装Numpy,scipy,matplotlib的安装
- 在linux上安装NumPy,Matplotlib,SciPy和IPython
- 在Ubuntu Linux 安装Python第三方库:NumPy,SciPy,Matplotlib, Scikit-Learn,Theao等
- linux中安装python科学计算环境-numpy、scipy、matplotlib、OpenCV...
- linux 下 安装 matplotlib 版本依赖(旧版本)
- linux中安装python科学计算环境-numpy、scipy、matplotlib、OpenCV...
- Linux环境下numpy,scipy,matplotlib的安装
- 在Linux中使用matplotlib进行科学画图
- Linux环境下修改python matplotlib显示中文乱码方格
- linux下安装numpy and matplotlib
- linux下python3.4配置matplotlib的问题
- matplotlib绘图:figure的导航快捷键
- Custom tool error: Failed to generate code for the service reference ××××××. Please check other erro
- 在Linux下使用Python的matplotlib绘制数据图的教程
- 在Linux下使用Python的matplotlib绘制数据图的教程
- Linux下python matplotlib.pyplot在图像上显示中文的问题