Matplotlib:使x轴变长 [英] Matplotlib: make x-axis longer

查看:4080
本文介绍了Matplotlib:使x轴变长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matplotlib 中,我需要绘制一个图表,其中包含 1 5000 ,并且在y轴上的范围非常有限。

/ code>自动压缩所有内容,让所有数据都放在(横向)页面上。就我而言,我希望x轴尽可能大,以便所有点清晰可见。现在,只有一条粗大的彩色线条,而不是分散的点。



我该怎么做?

(我保存为pdf,如果有帮助)

解决方案

您可以随时尝试指定尺寸你正在创造的数字。以下行可能有帮助:
$ b $ pre $ fig = plt.figure(figsize =(20,2))
ax = fig.add_subplot(111)
ax.plot(x,y)

figsize 以宽度为单位,以英寸为单位的高度。


In Matplotlib I need to draw a graph with points on the x-axis on each integer between 1 and 5000 and on the y-axis only in a very limited range.

Matplotlib automatically compacts everything to let all the data fit on a (landscape) page. In my case I would like the x-axis to be as large as possible so that all points are clearly visible. Right now there's just a thick coloured line as opposed to scattered points.

How can I do this?

(I'm saving to pdf, if that helps)

解决方案

You can always try to specify the dimensions (in inches) of the figure you are creating. Something along the following line might help:

fig = plt.figure(figsize=(20, 2))
ax = fig.add_subplot(111)
ax.plot(x, y)

The figsize takes a tuple of width, height in inches.

这篇关于Matplotlib:使x轴变长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆