将boxplot添加到python中的其他图形 [英] add boxplot to other graph in python
本文介绍了将boxplot添加到python中的其他图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这两个图的每个点的x轴值完全相同,是否可以在第一个图的顶部显示盒子晶须?
These two graphs have exactly the same x axis value of each point, is it possible to display the box whisker on top of the first graph?
我尝试过:
fig1 = plt.figure()
ax = fig1.add_subplot(211)
ax.set_xscale('log')
ax.plot(x7,y7,'c+-')
ax.plot(x8,y8,'m+-')
ax.plot(x9,y9,'g+-')
ax.boxplot(dataset)
xtickNames = plt.setp(ax, xticklabels=boxx)
plt.setp(xtickNames)
结果仅显示框晶须图,而没有其他三行,因此,我改为尝试此操作:
The results only display the box whisker graph without the other three lines, so, I tried this instead:
fig1 = plt.figure()
ax = fig1.add_subplot(211)
ax2 = fig1.add_subplot(212)
ax.set_xscale('log')
ax.plot(x7,y7,'c+-')
ax.plot(x8,y8,'m+-')
ax.plot(x9,y9,'g+-')
ax2.set_xscale('log')
ax2.boxplot(dataset)
xtickNames = plt.setp(ax2, xticklabels=boxx)
plt.setp(xtickNames)
但是我希望它们可以在同一张图中显示吗?
But I want them to be shown in the same graph, is that possible?
推荐答案
如果希望X和Y范围相近的两个图出现在另一个图的上方,则可以尝试保持。例如:
If you want two graphs with comparable X and Y ranges to appear one on top of the other, you can try "Hold". For example:
import pylab
pylab.plot([1,2,3,4],[4,3,2,1])
pylab.hold(True)
pylab.plot([1,2,3,4],[1,2,3,4])
这篇关于将boxplot添加到python中的其他图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文