简体   繁体   English

对数刻度机智 matplotlib 中的 x-ticks 问题

[英]Issues with x-ticks in log-scale wit matplotlib

I have a figure in log-scale and would like to set the x-ticks manually to [0.5, 1, 2]:我有一个对数刻度的数字,想手动将 x-ticks 设置为 [0.5, 1, 2]:

import matplotlib.pyplot as plt

ax = plt.gca()

ax.set_xscale("log")
ax.set_xticks([0.5,1,2])
ax.set_xticklabels([.5,1,2])
ax.set_xlim([0.5,2]) # issue causing line

However, it automatically also sets one to 6*10^-1, which I can't get rid off.但是,它也会自动将 1 设置为 6*10^-1,这是我无法摆脱的。 Even asking ax.get_xticks() doesn't show this x-tick.即使询问ax.get_xticks()也不会显示此 x-tick。 How can I get rid of the unwanted tick?我怎样才能摆脱不需要的蜱虫?

在此处输入图片说明

That looks like a minor tick.这看起来像一个小勾。 Try adding尝试添加

ax.set_xticks([], minor=True)

Output:输出:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM