Qt平台插件问题Rstudio [英] Qt platform plugin issue Rstudio
问题描述
我正在尝试通过RStudio绘制海洋图.
I am trying to do a seaborn heatmap plot via RStudio.
我在R中使用reticulate
包.
下面是我的代码:
library(reticulate)
use_condaenv("python36", conda = "auto", required = FALSE)
os <- import("os")
os$listdir(".")
py_available()
sns <- import('seaborn')
plt <- import('matplotlib.pyplot')
pd <- import('pandas')
dat <- AirPassengers
# convert time series to data frame
dat <- data.frame(matrix(dat, ncol=frequency(dat), dimnames=dimnames(.preformat.ts(dat)) ))
dat
sns$heatmap(r_to_py(dat), fmt = "g", cmap = "viridis")
plt$show()
但是,我收到以下错误,并且当我的R会话到达最常见的热图线时,我的R会话被中止了.我该怎么办才能解决此错误?
However, I receive the following error and my R session gets aborted when it reaches the seaborn heatmap line. What should I do to fix this error?
推荐答案
我在RStudio每日内部版本1.2.114和安装了PyTorch和matplotlib
的Anaconda Python 3.7环境中遇到了相同的问题.
I had the same problem with RStudio daily build 1.2.114 and a Anaconda Python 3.7 environment where I had PyTorch and matplotlib
installed.
我按照@Sheperd的说明进行了以下更改,指向您已安装matplotlib
的环境;就我而言pytorch37
:
I followed the instructions by @Sheperd, with the following changes, pointing to the environment where you have matplotlib
installed; in my case pytorch37
:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import os
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = 'C:/Users/user_name/Anaconda3/envs/pytorch37/Library/plugins/platforms'
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
plt.show()
现在,找到了PyQt
并且 RStudio 不再崩溃.
Now, PyQt
is found and RStudio doesn't crash anymore.
这篇关于Qt平台插件问题Rstudio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!