我正在使用matplotlib绘制图形,该函数将被称为多次。如何使图形绘制速度更快?
我读到有一个称为pyqt的库,可用于更快的图形绘图,可以代替matplotlib。我该如何在现有的代码中使用它。
import seaborn as sns
import numpy as np
def heatmap2d(arr: np.ndarray):
sns.heatmap(test_array, linewidths=10, square = True, vmin = 140, vmax=395, cmap='jet')
test_array = [
[220, 152, 146, 151, 146, 144],
[142, 156, 290, 174, 152, 151],
[148, 190, 390, 370, 146, 152],
[143, 142, 380, 375, 146, 152],
[154, 146, 154, 172, 150, 152],
[150, 152, 144, 140, 142, 0]
]
heatmap2d(test_array)
I have read that there is a library called pyqt which can be used for faster graph plotting and can be used in place of matplotlib. How can I use that in my existing piece of code.
import seaborn as sns
import numpy as np
def heatmap2d(arr: np.ndarray):
sns.heatmap(test_array, linewidths=10, square = True, vmin = 140, vmax=395, cmap='jet')
test_array = [
[220, 152, 146, 151, 146, 144],
[142, 156, 290, 174, 152, 151],
[148, 190, 390, 370, 146, 152],
[143, 142, 380, 375, 146, 152],
[154, 146, 154, 172, 150, 152],
[150, 152, 144, 140, 142, 0]
]
heatmap2d(test_array)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
希望您喜欢使用这个Pyqtgraph,是的,对于大量数据,这非常快速且可靠。这是使用pyqtgraph的数据的工作示例。
在这里,我使用PYQT5窗口显示图像,对我来说更容易。
Note :如果需要,您可以创建自己的colormap。
Hope you enjoy doing with this pyqtgraph, Yes, this is pretty fast and reliable for large number of data. Here is the working example with your data using pyqtgraph.
Here, I am using PyQT5 window to display image, its easier for me to do so.
Note: You can create your own colormap if it is necessary.