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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值