我想在 C# 中显示椭圆。我的代码在 R 中运行时很好,但我从 c# 收到如下消息:“对象是静态的;不允许操作(来自 HRESULT 的异常:0x8004000B(OLE_E_STATIC))”
这是我的代码:
df.rconn.Evaluate("library(cluster)")
df.rconn.Evaluate("library(rrcov)")
public void setScatter(int xAxis, int yAxis, int zAxis, List<string> variable)
{
// plot from R
//to show outlier with method : classic & robust Mve
this.comboBoxXAxis.SelectedIndex = xAxis;
this.comboBoxYAxis.SelectedIndex = yAxis;
dataform.rconn.EvaluateNoReturn("x<-X[," + xAxis + "] ");
dataform.rconn.EvaluateNoReturn("y<-X[," + yAxis + "] ");
dataform.rconn.EvaluateNoReturn("shape <- cov(X)");
dataform.rconn.EvaluateNoReturn("center<- colMeans(X)");
dataform.rconn.EvaluateNoReturn("d2.95 <- qchisq(0.95, df = 2)");
//dataform.rconn.EvaluateNoReturn("gr<- grid(lty=3,col='lightgray', equilogs = 'TRUE')");
//dataform.rconn.Evaluate("mtext('with classical (red) and robust (blue)')");
dataform.rconn.EvaluateNoReturn("plot(x,y, main='Draw Ellipse ', pch=19,col='black', type='p')");
dataform.rconn.EvaluateNoReturn("elp<- unname(ellipsoidPoints(shape, d2.95,center))");
dataform.rconn.Evaluate(" lines(elp, col='red' , lty=7 , lwd=2)");
//dataform.rconn.EvaluateNoReturn("lines(e)");
//dataform.rconn.EvaluateNoReturn("lines(ellipsoidPoints(mve@cov, d2 = d2.95, loc=mve@center), col='blue', lty='7' , lwd='2') ");
axGraphicsDevice2.RemoveFromConnector();
}
在我评论的任何代码中总是会出现相同的错误。我不知道为什么会出现这个问题。知道如何显示那个椭圆吗?非常感谢您,因为您帮助我完成了论文。