Excel VBA SeriesCollection 具有不同 xvalue 比例的两个系列

标签 excel vba

我尝试在 Excel 中的 vba 中在一个图表中绘制两个图表。一种是离散 x 范围从 -10 到 10,另一种是近似“连续”高斯分布,范围从 -10 到 10,步长为 0.1。

 Dim xvalue_norm(201) As Double
 Dim NormFassung(201) As Double
 Dim c As Integer

 For i = 1 To 20
    For j = 1 To 10
        c = c + 1               
        xvalue_norm(c) = i - 11 + (j - 1) / 10 '(-10,-9.9,-9.8,...,10)
        NormFassung(c) = WorksheetFunction.NormDist(i - 11 + (j - 1) / 10, mean_fassung, sigma_fassung, False)
    Next j
 Next i

Dim xvalue_hist(21) As Double
Dim HistFassung(21) As Double

For i = 1 To 21
    xvalue_hist(i) = (i - 11) '(-10,-9,-8,...,10)
    HistFassung(i) = Fassung(i) / summe_fassung
Next i


 ActiveSheet.Shapes.AddChart.Select
 ActiveChart.ChartType = xlLine 
 ActiveChart.Location Where:=xlLocationAsNewSheet     
 ActiveChart.Axes(xlValue).MinimumScale = 0
 ActiveChart.Axes(xlValue).MaximumScale = 0.5

    'Series 1 :
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(1).Name = "NormVert"
    ActiveChart.SeriesCollection(1).XValues = xvalue_norm
    ActiveChart.SeriesCollection(1).Values = NormFassung

    'Series 2 :
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(2).Name = "Historie"
    ActiveChart.SeriesCollection(2).XValues = xvalue_hist
    ActiveChart.SeriesCollection(2).Values = HistFassung

该图已使用从 -10 到 10 的正确 x 值范围正确初始化,并且第一个系列绘制得很好,但系列 2“历史”的 x 值似乎使用范围(-10,-9.9,-9.8 ,...,-8) 而不是离散值 (-10,-9,-8,...,10)。

最佳答案

抱歉,以下符号未定义,因此代码无法编译。

i , j, mean_fassung, sigma_fassung, summe_fassung

很难进步。

关于Excel VBA SeriesCollection 具有不同 xvalue 比例的两个系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23104572/

相关文章:

javascript - jquery datatable 表工具导出到 Excel 未向我显示文件中的表数据

vba - 如何从 Excel 调用 Word 宏

VBA - 窗体类没有显示方法

excel - 当第一个参数为 false 时,VBA "And"运算符是否计算第二个参数?

c# - 将excel中的数据导入到多个表中

python - 如何有效地在列表末尾添加逗号?

excel - 删除除空格外的所有特殊字符

string - VBA 分割字符串循环

python - Pandas:解析 Excel 中的合并标题列

Excel VBA排序不起作用worksheet.range引用的正确语法是什么