python设置子图的坐标_Python的 matplotlib画图,怎么把子图的每个横坐标显示出来?,...

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()

版权声明:本站所有文章皆为原创,欢迎转载或转发,请保留网站地址和作者信息。


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部