python - 如何正确处理彩条?
问题描述
在阅读了文档后,我一直在为 matplotlib 理解何时使用 fig/ax/plt 而苦苦挣扎。现在,我只想给颜色条一个标题,但我总是不知道要在哪些对象中存储所有内容以及以后使用哪些对象。
我能得到一个一般性的解释来避免走这条路吗?有没有更合适的方法我应该将热图传递给 ax,这样我就不会再遇到这个麻烦了?
activity = 'Downstairs'
layer = 1
seg_x = create_segments_and_labels(df[df['ActivityEncoded']==mapping[activity]],TIME_PERIODS,STEP_DISTANCE,LABEL)[0]
get_layer_output = K.function([model_m.layers[0].input],[model_m.layers[layer].output])
layer_output = get_layer_output([seg_x])[0]
try:
ax = sns.heatmap(layer_output[0].transpose())
except:
ax = sns.heatmap(layer_output.transpose())
ax.set_xlabel('Kernels',fontsize=30)
ax.set_yticks(range(0,len(layer_output[0][0])+1,10))
ax.set_yticklabels(range(0,len(layer_output[0][0])+1,10))
ax.set_xticks(range(0,len(layer_output[0])+1,5))
ax.set_xticklabels(range(0,len(layer_output[0])+1,5))
ax.set_ylabel('Filters',fontsize=30)
ax.xaxis.labelpad = 10
ax.set_title('Filters vs. Kernels\n (Layer=' + model_m.layers[layer].name + ')(Activity=' + activity + ')',fontsize=35)
#I'd like to add text to the colorbar but I don't know how to get it here. Fig/plt/ax.colorbar() don't work
clb = fig.colorbar()
错误:colorbar() 缺少 1 个必需的位置参数:'mappable'
解决方案
推荐阅读
- postgresql - 在 Eclipse 中运行 tomcat 服务器
- python - ax.patches 用于访问 python 中的子图
- c# - FormClosing处理ErrorProvider
- ajax - 为什么我的 Laravel 网站应用程序每次都显示“CSRF MISMATCH”?
- python - 网页抓取时如何在数据框中获得正确的值?
- reactjs - 如何将 React 本地状态存储到 Redux 全局存储(HOOKS)
- php - 如何缩小 php 文件的输出,其中包含另一个 php?
- php - 每页的WordPress自定义链接并显示它
- php - 上交时的PERMISSION_DENIED课堂api,即使课程作业也是使用课堂api创建的
- javascript - 从 spring 控制器动态创建 HTML 文本框