python等值线标注间距、控制_在Matplotlib中设置条间距我不知道如何控制下⾯代码中从⽂件中读取数据的条间距。是否有任何⽅法来调整/调整条之间的空间(不是栏的宽度)?在Input file:
1 4500
2 5000
3 3000
4 4000
5 1000
6 5000#!/usr/bin/python
import numpy as np
import pylab as plot
import matplotlib.pyplot as plt
import numpy, scipy, pylab, random
from matplotlib.ticker import MultipleLocator
import matplotlib as mpl
matplotlib中subplot
from matplotlib.ticker import MaxNLocator
with open("", "r") as f:
x=[]
y=[]
for line in f:
if not line.strip() or line.startswith('@') or line.startswith('#'): continue
row = line.split()
x.append(float(row[0]))
y.append(float(row[1]))
fig = plt.figure(figsize=(3,2))
ax = plt.subplot(111)
plt.ylim(0, 6000)
ax.yaxis.set_major_locator(MaxNLocator(6))
ax.yaxis.set_minor_locator(MultipleLocator(500))
plt.xlim(0+0.5, 7-0.5)
bars=plt.bar(x,y, width=0.2, color='blue', edgecolor='black', align='center', linewidth=0.5)
bars[0].set_facecolor('gray')
bars[1].set_facecolor('orange')
bars[2].set_facecolor('green')
bars[3].set_facecolor('yellow')

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。