python如何定义坐标
def coordinate(x, y):
if x>0:
if y>0:
a = 1
else:
a = 2
else:
if y>0:
a = 3
else:
a = 4
return a #根x,y返aif __name__ == "__main":
print 'Please insert X,Y'
x = input('Please insert X')
y = input('Please insert Y')
print coordinate(x,y)
Python的 matplotlib画图,怎么把子图的每个横坐标显示出来?
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] # 正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
fig = plt.figure(figsize=(20, 20), dpi=80)
ax1 = fig.add_subplot(2,2,1)
x = range(5)
y = [2, 2, 5, 2, 4]
s = ['数1', '数量2', '数量3', '数量4', '数量5']
plt.bar(x, y, width=0.5)
plt.xticks(x, s, rotation=270)
plt.xlabel('数据情况' )
plt.ylabel('数量(个)')
for xl, yl in zip(x, y):
plt.text(xl, yl 0.3, str(yl), ha='center', va='bottom', fontsize=10.5)
ax2 = fig.add_subplot(2,2,2)
plt.bar(range(4), [3, 4,2,3], width=0.3)
ax3 = fig.add_subplot(2,2,3)
plt.bar(range(4), [3, 4,2,3], width=0.3)
ax4 = fig.add_subplot(2,2,4)
plt.bar(range(4), [3, 4,2,3], width=0.3)
plt.show()
版权声明:本站所有文章皆为原创,欢迎转载或转发,请保留网站地址和作者信息。