你能帮我弄清楚如何用matplotlib绘制这种图吗?
我有一个pandas数据框对象表示表:
Graph n m
<string> <int> <int>
我想可视化每个n
和m
的大小:一个水平条形图,其中每一行的y轴左侧有一个包含Graph
名称的标签;y轴右侧有两个彼此正下方的细水平条,其长度表示n
和m
。应该清楚地看到,这两个细条都属于用图形名称标记的行。
这是我到目前为止写的代码:
fig = plt.figure()
ax = gca()
ax.set_xscale("log")
labels = graphInfo["Graph"]
nData = graphInfo["n"]
mData = graphInfo["m"]
xlocations = range(len(mData))
barh(xlocations, mData)
barh(xlocations, nData)
title("Graphs")
gca().get_xaxis().tick_bottom()
gca().get_yaxis().tick_left()
plt.show()
听起来你想要的东西和这个例子非常相似:http://matplotlib.org/examples/api/barchart_demo.html
首先:
现在的问题和答案有点陈旧了。Based on the documentation这现在简单多了。
相关问题 更多 >
编程相关推荐