简体   繁体   English

寻找创建折线图的方法,y 轴上有文字,x 轴上有相应的数字

[英]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.最简单的方法是使用 python 模块 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.列表中的值 xvalues[] 和 yvalues[] 可以毫无问题地替换为单词,但是它们应该在 " " 之间以显示它是字符串。 For more information about matplotlib you could always go to matplotlib.org.有关 matplotlib 的更多信息,您可以随时访问 matplotlib.org。 I hope this is helpfull.我希望这会有所帮助。

暂无
暂无

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

相关问题 Matplotlib水平条形图,沿y轴带有x轴标签 - Matplotlib horizontal bar graph with x-axis label along y-axis python pandas:如何为折线图切换x轴和y轴 - python pandas: how to switch x-axis with y-axis for a line graph 创建一个折线图,x 轴为日期时间,y 轴为记录数 - Create a line chart with datetime on x-axis and number of records on y-axis 使用 Seaborn 或 Matplotlib 生成折线图,其中:年为色调,月为 X 轴,浮点列为 Y 轴 - Generating a Line Graph using Seaborn or Matplotlib with: Year as hue, Month as X-Axis and Float Column as Y-Axis 有没有办法用 plotly 或 python 创建条形图可视化,其中 y 轴是 24 小时范围,x 轴是所有工作日? - Is there a way to create a bar graph visualization with plotly or python where the y-axis is 24hour range and x-axis is all the weekdays? 有没有一种方法可以创建一个图表,该图表在其自己的 x 轴上迭代了成对的连续项目,并在其自己的 y 轴上迭代了这些项目对的值? - Is there a way to create a graph that has iterated pairs of consecutive items in its own x-axis and values of the pairs in its own y-axis? 我想交换 x 轴和 y 轴并将此图更改为水平图 python - I want to swap x-axis and y-axis and change this graph to horizontal graph python 在一张图中绘制多条线,x 轴上以月为单位,y 轴上出现次数 - Plotting multiple lines in one graph with time in months on the x-axis, number of occurences on the y-axis matplotlib 从 x 轴而不是 y 轴绘制累积图 - matplotlib plot on cumulative graph from x-axis instead of y-axis 当 x 轴为日期且 y 轴为日志时,将文本添加到 Seaborn 图表 - Adding Text to Seaborn Graph when x-axis is dates and y-axis is logs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM