Python :( Seaborn?)来自不规则网格的热图

时间:2016-06-02 13:57:04

标签: python pandas matplotlib seaborn

假设我有两个给定的网格物体(例如测量数据):

  • grid_1的范围为x=(-10...10); y=(-10...10),步长为1
  • grid_2范围为x=(-30...-10) & x=(10...30); y=(-30...-10) & y=(10...30),步长为5,所以它有一个洞 grid_1的大小
  • 我对两个网格网格的每对'dose'都有z值(xi, yi) 并且两个数据集都以包含三列x, y, dose
  • 的表格的形式出现

我尝试使用seaborn的heatmap()函数绘制此数据的热图表示:

dm1 = df1.pivot('y', 'x', 'dose')
opts = {'cmap': 'YlGnBu_r'}
ax = sns.heatmap(dm1, **opts)
ax.invert_yaxis()
plt.savefig('dosemap-test-smooth.pdf')

dosemap-smooth

dm2 = df2.pivot('y', 'x', 'dose')
ax = sns.heatmap(dm2, **opts)
ax.invert_yaxis()
plt.savefig('dosemap-test-coarse.pdf')

dosemap-coarse

df = df1.append(df2)
dm = df.pivot('y', 'x', 'dose')
ax = sns.heatmap(dm2, **opts)
ax.invert_yaxis()
plt.savefig('dosemap-test-total.pdf')

dosemap-total

将两个网格物体彼此独立地绘制起来效果很好,但将它们绘制在一起会破坏热图的分级(?)。 所以我的问题是:我如何能够不定期地绘制一个热图(类似)的表示形式。使用python分发数据? :)

提前感谢您的帮助!

0 个答案:

没有答案
相关问题