我有一个sales pandas数据框,其中每一行代表一个公司名称,有四列显示最近五年的当前、最小、最大和平均销售额。在
我想知道是否有一种方法来绘制数据帧内的最小值、最大值、平均值、当前水平线。在
举个具体的例子:
https://libguides.lib.umanitoba.ca/bloomberg/fixedincome
如果你看一下“Range”列,那正是我试图在dataframe中复制的内容。我找到了matplotlib boxplot,但我不认为我能在数据帧中绘制它们。在
你知道有什么解决办法吗?在
Tags:
我不太清楚你到底在找什么,所以如果你还需要什么,请告诉我。在
我使用pandas为图形创建一些虚拟数据和matplotlib。在
现在是重要的部分。我从图片中重现了你的例子。这个循环迭代数据帧中的每一行,也就是公司。结果就是你有多少个公司就有多少个图表。在
ax.plot
创建一条从minimum
值到maximum
值。在ax.scatter
为current
和average
值创建点。在当然,您必须稍微调整图形,使其看起来像您希望的那样。在
^{pr2}$这是第一家公司的图表。
编辑(参见@Andrea的评论):将绘制的数据放在一起
您可以按照上面的方法,但调整图形的样式。在
这看起来很接近你在问题中发布的图片。
好的,基于NK_u帮助和内容: Matplotlib- Creating a table with line plots in cells?
我总算把它拼在一起了:
老实说,我不知道我编写的代码是否是我可以使用的最好的代码,有许多部分我还需要理解。在
最后一个问题是: 有人能帮我在这张表上加上第一行,用粗体显示每一列的标题吗? 谢谢
相关问题 更多 >
编程相关推荐