python - Matplotlib 标签重叠,因为数据太多
问题描述
这是我在 python 语言的 jupyter notebook 中的代码。 我在垂直方向有距离,在水平方向有时间。 当数据泛滥(太多)时,水平标签会相互重叠。你根本看不懂标签。我怎样才能拥有框架的动态宽度?或者也许其他解决方案非常受欢迎。谢谢
#this code below is to append the data
if i==0:
time = [timetable[i][0]]
else:
time.append(timetable[i][0])
if timetable[i][1][:-2].lower() == 'driver':
distances.append(0)
elif timetable[i][1][:-2].lower() == 'rider':
distances.append(rider_request)
print(time, len(time))
print(distances, len(distances))
#dataframe for plot graph
df=pd.DataFrame({'x': time, 'y': distances })
# plot
plt.plot( 'x', 'y', data=df, linestyle='-', marker='o')
plt.show()
解决方案
推荐阅读
- php - Laravel 模型 save() 方法没有返回正确的 ID?
- javascript - 在 Promise 中移除事件监听器
- nearprotocol - NEAR 上的智能合约有事件还是我需要轮询链来获取数据?
- spring - Spring security JWT 过滤器抛出 500 和 HTML 而不是 401 和 json
- python-3.x - python3:字节与字节数组,并转换为字符串和从字符串转换
- php - Laravel邮件,不能将变量传递给主题,但它可以在正文中使用
- javascript - pdf.js:循环搜索文本的页面
- python - Python - 尝试查找当前是否正在运行 sikuli 脚本
- python-3.x - TypeError:需要字符串参数,得到“字节”
- python - 在python中注释绘图时出现KeyError