Python 3.x 增加python matplotlib中y轴的长度
我通过matplotlib库获得了这张图像 现在我只想增加y轴的长度,以获得更清晰的视图 代码如下:Python 3.x 增加python matplotlib中y轴的长度,python-3.x,matplotlib,Python 3.x,Matplotlib,我通过matplotlib库获得了这张图像 现在我只想增加y轴的长度,以获得更清晰的视图 代码如下: plt.figure(1) plt.subplot(211) plt.plot_date(df['Condition'],df['Date'], tz=None, xdate=True, ydate=False) plt.title('Scatter plot') plt.xlabel('Condition') plt.ylabel('Date') plt.show() 这应该能回答你的问题
plt.figure(1)
plt.subplot(211)
plt.plot_date(df['Condition'],df['Date'], tz=None, xdate=True, ydate=False)
plt.title('Scatter plot')
plt.xlabel('Condition')
plt.ylabel('Date')
plt.show()
这应该能回答你的问题 轴=plt.gca() axes.set_xlim([xmin,xmax])
axes.set_ylim([ymin,ymax])您需要更改图形大小。这可以通过向提供给
plt的figsize
关键字参数提供元组来控制。图
:
import matplotlib.pyplot as plt
plt.figure(1, figsize=(4, 6)) # Figure size in inches (size_x, size_y)
plt.subplot(211)
# plt.plot_date(df['Condition'],df['Date'], tz=None, xdate=True, ydate=False)
plt.title('Scatter plot')
plt.xlabel('Condition')
plt.ylabel('Date')
plt.show()
以上几行创建了下图:
y轴上的日期是动态的。如何从中找到最小和最大日期?这可能会有所帮助。如果试图限制x轴,使其范围从静态最小值到动态最大值,并且最大值是数据集中最大的datetime对象,请尝试#。。。plt.xlim(xmin=datetime.datetime(2017,1,4,hour=13),#不改变xmax=max(x)#数据集中的最新日期时间)-1:OP的图像和问题清楚地表明他们希望绘图区域更大,而不是改变可视化边界(这实现了)。