简体   繁体   中英

Looking for ways to create a line graph, with words along y-axis and numbers accordingly, on the x-axis

Sorry if this seems simple, but I am only a student beginning coding and need this to complete a school project. I have my graph ready but am unable to find a way to attach my number statistics to their belonging titles. Any suggestions welcome.

import matplotlib.pyplot as plt

xvalues = [1, 2, 3, 4, 5, 6]
yvalues = [1, 2, 4, 8, 16, 32]

plt.plot(xvalues, yvalues)
plt.ylabel('y axis')
plt.xlabel('x axis')
plt.show()

Im not very experienced, however I am willing to help you. The easiest way to do this is by using the python module matplotlib. Using this module you can create a simple graph with the script above. The values in the lists xvalues[] and yvalues[] can be replaced by words without any problem, however they should be between " " to show it are strings. For more information about matplotlib you could always go to matplotlib.org. I hope this is helpfull.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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