在Matplotlib中更改X轴比例 [英] Change x axes scale in matplotlib

查看:152
本文介绍了在Matplotlib中更改X轴比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Matlab创建了该图

使用matplotlib,x轴绘制大量数字,例如100000、200000、300000.我想用1、2、3和10 ^ 5表示它实际上是100000、200000、300000. /p>

有没有一种简单的方法可以在matplotlib中创建这样的比例尺?

解决方案

尝试使用 matplotlib.pyplot.ticklabel_format :

import matplotlib.pyplot as plt
...
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))

这会将科学符号(即a x 10^b)应用于您的x轴刻度线

I created this plot using Matlab

Using matplotlib, the x-axies draws large numbers such as 100000, 200000, 300000. I would like to have something like 1, 2, 3 and a 10^5 to indicate that it's actually 100000, 200000, 300000.

Is there a simple way to create such scale in matplotlib?

解决方案

Try using matplotlib.pyplot.ticklabel_format:

import matplotlib.pyplot as plt
...
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))

This applies scientific notation (i.e. a x 10^b) to your x-axis tickmarks

这篇关于在Matplotlib中更改X轴比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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