Can you help me figure out how to draw this kind of plot with matplotlib?
I have a pandas data frame object representing the table:
Graph n m
<string> <int> <int>
I want to visualize the size of n
and m
for each Graph
: A horizontal bar chart where for each row, there is a label containing the Graph
name to the left of the y-axis; to the right of the y-axis, there are two thin horizontal bars directly below each other, whose length represents n
and m
. It should be clear to see that both thin bars belong to the row labelled with the graph name.
This is the code I have written so far:
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()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…