当前位置:网站首页>matplotlib设置坐标轴刻度间隔
matplotlib设置坐标轴刻度间隔
2022-06-22 18:28:00 【单单一个越字】
本来是想让横轴显示1-20的整数,刻度之间间隔1,但是画出图来却显示有浮点数
plt.title('train loss')
plt.plot(np.arange(1,len(losses)+1), losses)
plt.plot(np.arange(1,len(eval_losses)+1), eval_losses)

经查资料,找到两种方法:
第一种是通过MultipleLocator类来实现
from matplotlib.pyplot import MultipleLocator #导入此类,设置坐标轴间隔
plt.title('train loss')
x_major_locator=MultipleLocator(1)
ax=plt.gca()
ax.xaxis.set_major_locator(x_major_locator)
plt.plot(np.arange(1,len(losses)+1), losses)
plt.plot(np.arange(1,len(eval_losses)+1), eval_losses)

第二种是将横轴坐标范围转换成字符串
plt.title('train loss')
plt.plot(np.arange(1,len(losses)+1).astype(np.str), losses)
plt.plot(np.arange(1,len(eval_losses)+1), eval_losses)

边栏推荐
- 2.什么是机械设计?
- 510000 prize pool invites you to join the war! The second Alibaba cloud ECS cloudbuild developer competition is coming
- MySQL约束
- Explain in simple terms the bloom filter
- About Random Forest
- AttributeError: ‘KeyedVectors‘ object has no attribute ‘wv‘
- 0.0 - Solidworks如何才能卸载干净?
- Flutter series -flutter route management
- C #, introductory tutorial -- a little knowledge about function parameter ref and source program
- Flutter series -dart basic grammar learning
猜你喜欢

1.2-----机械设计工具(CAD软件)和硬件设计工具(EDA软件)及对比

Activereports report practical application tutorial (19) -- multi data source binding

如何用银灿IS903主控DIY自己的U盘?(练习BGA焊接的好项目)

Problems of different renderers running on the web with flutter2.0

Common technical notes
![K个一组翻转链表[链表拆解/翻转/拼装]](/img/70/fb783172fa65763f031e6bd945cbd9.png)
K个一组翻转链表[链表拆解/翻转/拼装]

Nrf51822 peripheral learning

K8s deploy MySQL

Flutter series - build a flutter development environment

AB打包有的Shader没有触发IPreprocessShaders的回调
随机推荐
商业智能BI数据仓库中的指标、维度和模型到底是什么?
生产系统SQL执行计划突然变差怎么办?
510000 prize pool invites you to join the war! The second Alibaba cloud ECS cloudbuild developer competition is coming
MySQL数据库DQL练习题
.Net 5.0 通过IdentityServer4实现单点登录之oidc认证部分源码解析
K8s deploy MySQL
A homekit enabled camera? Zhiting IPC camera IC1 unpacking experience
[nfs无法挂载问题] mount.nfs: access denied by server while mounting localhost:/data/dev/mysql
08_一句话让你人间清醒
[dry goods | necessary skills for interface testing common interface protocol analysis]
0.1----- process of drawing PCB with AD
0.0 - Solidworks如何才能卸载干净?
Openpnp debugging ------ 0816 Feida Tui 0402 taping
C #, introductory tutorial -- a little knowledge about function parameter ref and source program
Digital commerce cloud: analyze the design idea of B2B2C multi-user mall system architecture, and open a new era of intelligent mall
修改隐含参数造成SQL性能下降案例之一
Ts as const
Ts as const
The custom control autoscalemode causes the problem of increasing the width of font
0816 shortcomings of Feida (improvement direction)