python – matplotlib中的背对背直方图

python – matplotlib中的背对背直方图,第1张

概述有一个很好的功能,在Matlab中绘制 back to back histograms.我需要在matplotlib中创建一个类似的图形.有谁能展示一个有效的代码示例? 感谢Mark Rushakoff指出的链接,以下是我最终做的事情 import numpy as npfrom matplotlib import pylab as pldataOne = get_data_one()da 有一个很好的功能,在Matlab中绘制 back to back histograms.我需要在matplotlib中创建一个类似的图形.有谁能展示一个有效的代码示例?解决方法 感谢Mark rushakoff指出的链接,以下是我最终做的事情

import numpy as npfrom matplotlib import pylab as pldataOne = get_data_one()dataTwo = get_data_two()hN = pl.hist(dataTwo,orIEntation='horizontal',normed=0,rwIDth=0.8,label='ONE')hS = pl.hist(dataOne,bins=hN[1],label='TWO')for p in hS[2]:    p.set_wIDth( - p.get_wIDth())xmin = min([ min(w.get_wIDth() for w in hS[2]),min([w.get_wIDth() for w in hN[2]]) ])xmin = np.floor(xmin)xmax = max([ max(w.get_wIDth() for w in hS[2]),max([w.get_wIDth() for w in hN[2]]) ])xmax = np.ceil(xmax)range = xmax - xmindelta = 0.0 * rangepl.xlim([xmin - delta,xmax + delta])xt = pl.xticks()n = xt[0]s = ['%.1f'%abs(i) for i in n]pl.xticks(n,s)pl.legend(loc='best')pl.axvline(0.0)pl.show()
总结

以上是内存溢出为你收集整理的python – matplotlib中的背对背直方图全部内容,希望文章能够帮你解决python – matplotlib中的背对背直方图所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1192300.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存