Ho fatto un grafico lineare in pitone con pyplot/matplotlib:Come si creano le lettere delle x-coordinate?
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()
Sul mio asse x, it scale di corrente di numeri. Tuttavia, voglio che gli incrementi sull'asse x siano etichettati con lettere (a, b, c, d) invece di dire 0, 5, 10 ... In particolare, voglio che la lettera 'a' sia mappata a 0, ' b 'per mappare a 1, ecc.
Come faccio a fare pyplot?
Grazie! 'pyplot.xticks (np.arange (0, 26), string.lowercase)' funziona! – dangerChihuahua007