python - 将数据着色器添加到 matplotlib 子图 - 位置参数错误
问题描述
我想使用数据着色器输出作为 plt 子图的输入。
我正在尝试运行此问题的答案中建议的代码: Add datashader image to matplotlib subplots
下面是代码:
from datashader.mpl_ext import DSArtist
import datashader as ds
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import pandas as pd
import numpy as np
N = 10000
df = pd.DataFrame(np.random.random((N, 3)), columns = ['x','y', 'z'])
f, ax = plt.subplots(2, 2)
ax_r = ax.ravel()
da = DSArtist(ax_r[0], df, 'x', 'y', ds.mean('z'), norm = mcolors.LogNorm())
ax_r[0].add_artist(da)
ax_r[1].hist(df['x'])
ax_r[2].hist(df['y'])
ax_r[3].plot(df['z'])
plt.tight_layout()
plt.show()
我收到一个错误:
---> da = DSArtist(ax_r[0], df, 'x', 'y', ds.mean('z'), norm = mcolors.LogNorm())
TypeError: __init__() missing 7 required positional arguments: 'shade_hook', 'plot_width', 'plot_height', 'x_range', 'y_range', 'width_scale', and 'height_scale'
我尝试在此处查看 DSArtist 的源代码(https://github.com/holoviz/datashader/pull/200/files),但不太了解它。
如何解决错误?
谢谢!
解决方案
推荐阅读
- typescript - TypeScript 函数接受一个没有特定键的对象
- javascript - 在扩展面板上选择收音机会更改另一个组件 vuetify 中的属性
- batch-file - 批处理文件从不同的子文件夹中随机选择相同文件名的文件到一个文件夹
- kotlin - 如何让我的 JS 测试出现在 Kotlin Multiplatform 项目中
- amazon-web-services - 将外部身份提供程序与服务器端身份验证一起使用
- javascript - Firefox Web 扩展“无法访问死对象”错误
- javascript - 将 VAR 更改为数组以存储多个项目
- python - 正则表达式相同的模式仅适用于 1 个结果
- ruby-on-rails - 使用 Join Tables 的 Rails 关联
- python-3.x - 在 bash 中多行打印 python 文件的结果