我正在使用 C# 的图形库 OxyPlot。到目前为止,让我感到困惑的是type
一些构造函数。代码片段如下:
public static PlotModel Notinterpolatedvalues() {
var plotModel1 = new PlotModel();
plotModel1.Subtitle = "Input text here";
var linearColorAxis1 = new LinearColorAxis();
linearColorAxis1.HighColor = OxyColors.Gray;
linearColorAxis1.LowColor = OxyColors.Black;
linearColorAxis1.Position = AxisPosition.Right;
plotModel1.Axes.Add(linearColorAxis1);
var linearAxis1 = new LinearAxis();
linearAxis1.Position = AxisPosition.Bottom;
plotModel1.Axes.Add(linearAxis1);
var linearAxis2 = new LinearAxis();
plotModel1.Axes.Add(linearAxis2);
var heatMapSeries1 = new HeatMapSeries();
heatMapSeries1.X0 = 0.5;
heatMapSeries1.X1 = 1.5;
heatMapSeries1.Y0 = 0.5;
heatMapSeries1.Y1 = 2.5;
heatMapSeries1.Interpolate = false;
heatMapSeries1.Data = new Double[2, 3];
heatMapSeries1.Data[0, 0] = 0;
heatMapSeries1.Data[0, 1] = 0.2;
heatMapSeries1.Data[0, 2] = 0.4;
heatMapSeries1.Data[1, 0] = 0.1;
heatMapSeries1.Data[1, 1] = 0.3;
heatMapSeries1.Data[1, 2] = 0.2;
plotModel1.Series.Add(heatMapSeries1);
return plotModel1;
}
这将生成此图像:
(这是一张热图)
我的问题是 - 什么是var
?例如,当您创建一个新的多维数组时,您可以这样做:
double[,] doubleArray = new double[columns, rows];
可以理解的是,type
for this 是一个double[,]
. 为什么我需要知道这一点是我想将热图存储为实例变量,更具体地说,存储heatMapSeries1.Data
为多维数组。但是,在 VS 中,我无法声明var
为实例变量的类型。我得到的唯一选择是:
这里有任何 OxyPlot 专业人士可以帮助我吗?谢谢你。