Python图修复大小

时间:2016-07-05 05:10:07

标签: python matplotlib

感谢您阅读我的问题!

我使用Pyplot创建了情节,这是我的数据:

enter image description here

“点”数组的长度为:114745

“id_item”数组的长度为:114745

“sessions”数组的长度为:92128

这是我的代码:

point = []
id_item = []
sessions = [] # temp_dict.keys() 

for item in cursor_fromCompanyDB:
    sessions.append(item['sessionId'])
    for object_item in item['objects']:
        point.append(object_item['point'])
        id_item.append(object_item['id'])


plt.figure()
plt.title('Scatter Point and Id of SessionId', fontsize=20)
plt.xlabel('point', fontsize=15)
plt.ylabel('Item', fontsize=15)
plt.scatter(point, id_item, marker = 'o')
plt.autoscale(enable=True, axis=u'both', tight=False)

for label, x, y in zip(sessions, point, id_item):
    plt.annotate(label, xy = (x, y))

plt.show()

这就是结果:

enter image description here

如您所见,价值非常接近且难以看清。

我希望 id_item 中的值显示中心(会话)中的完整值和值很容易看到。

非常感谢帮助我。

1 个答案:

答案 0 :(得分:1)

有两种方法可以解决你的情节:

  1. 使图表变得如此之大,以至于您必须向下滚动页面以查看每个会话ID。
  2. 减少您的数据/不显示所有内容。
  3. 就个人而言,我选择选项2.在某个时刻,显示一定数量的点变得不可能或者只是非常难看,特别是分配给它们的标签。你必须在某个地方做出牺牲。

    编辑:如果你真的想改变你的数字大小,look here for a thread explaining how to do that