python如何表示坐标_python – 如何制作x坐标字母?

我在

python中使用pyplot / matplotlib创建了一个折线图:

import matplotlib.pyplot as plt

import math

import numpy as np

alphabet = range(0, 25)

firstLine = [letter + 65 for letter in alphabet]

secondLine = [letter + 97 for letter in alphabet]

plt.plot(alphabet, firstLine, '-b', label='ASCII value of capital.')

plt.plot(alphabet, secondLine, '--g', label='ASCII value of lowercase.')

plt.xlabel('Letter in Alphabet')

plt.ylabel('ASCII Value')

plt.title('ASCII value vs. Letter')

plt.legend()

plt.show()

在我的x轴上,它的电流按数字缩放.但是,我希望x轴上的增量用字母(a,b,c,d)标记,而不是说0,5,10 …具体来说,我希望字母’a’映射到0,’ b’映射到1等

我如何让pyplot这样做?

你可能感兴趣的:(python如何表示坐标)