C# 为什么在ZedGraph中Y轴非常小?
我有这个ZedGraph控制代码:C# 为什么在ZedGraph中Y轴非常小?,c#,C#,我有这个ZedGraph控制代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ZedGraph; using Extracting_Frames; namesp
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;
using Extracting_Frames;
namespace Lightnings_Extractor
{
public partial class Histogram_Graphs : Form
{
public long[] histogram;
public Histogram_Graphs()
{
InitializeComponent();
histogram = Form1.GetHistogramValue;
this.DoubleBuffered = true;
CreateGraph_GradientByZBars(zedGraphControl1);
}
private void Histogram_Graphs_Load(object sender, EventArgs e)
{
}
private void CreateGraph_GradientByZBars(ZedGraphControl z1)
{
GraphPane myPane = z1.GraphPane;
myPane.Title.Text = "Demonstration of Multi-Colored Bars with a Single BarItem";
myPane.XAxis.Title.Text = "Bar Number";
myPane.YAxis.Title.Text = "Value";
PointPairList list = new PointPairList();
Random rand = new Random();
for (int i = 0; i < histogram.Length; i++)
{
double x = (double)i + 1;
//double y = (double)i + 1;//rand.NextDouble() * 1000;
double z = i / 4.0;
list.Add(x, histogram[i], z);
}
BarItem myCurve = myPane.AddBar("Multi-Colored Bars", list, Color.Blue);
Color[] colors = { Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple };
myCurve.Bar.Fill = new Fill(colors);
myCurve.Bar.Fill.Type = FillType.GradientByZ;
myCurve.Bar.Fill.RangeMin = 0;
myCurve.Bar.Fill.RangeMax = 4;
myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45);
myPane.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 225), 45);
// Tell ZedGraph to calculate the axis ranges
z1.AxisChange();
}
}
}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Windows.Forms;
使用ZedGraph;
使用提取帧;
名称空间lightings\u提取器
{
公共部分类直方图:形式
{
公共长[]直方图;
公共直方图(U图)
{
初始化组件();
直方图=Form1.GetHistorogramValue;
this.DoubleBuffered=true;
创建Graph_GradientByzbar(zedGraphControl1);
}
私有无效直方图\图形\加载(对象发送方、事件参数e)
{
}
私有void CreateGraph_GradientByZBars(ZedGraphControl z1)
{
GraphPane myPane=z1.GraphPane;
myPane.Title.Text=“用一个BarItem演示多色条”;
myPane.XAxis.Title.Text=“条号”;
myPane.YAxis.Title.Text=“值”;
PointPairList=新的PointPairList();
Random rand=新的Random();
对于(int i=0;i
问题在循环中:
for (int i = 0; i < histogram.Length; i++)
{
double x = (double)i + 1;
//double y = (double)i + 1;//rand.NextDouble() * 1000;
double z = i / 4.0;
list.Add(x, histogram[i], z);
}
for(int i=0;i
这是随机的。现在我想使用直方图列表中的值。
例如,在索引[0]中有一个数字:34118,然后在索引1521中,索引[2]522
列表中有256个索引
当我看到图表时,我看到诗人的身高很短
在图表的开头,我看到一行非常高,但接下来的所有行都非常短。
在Y轴上,我看到侧面的数字从0到40,在x轴上,我看到数字从0到300
在Y轴上,我应该看到从0到直方图中最高值的数字,在X轴上,我应该看到从0到256的数字
这里一团糟
我该怎么修
谢谢
您的代码中没有bug。您的图形准确地绘制了
直方图[]
数组中的值
您提到数组包含以下值:
histogram[0] = 34118
histogram[1] = 1521
histogram[2] = 522
...
如果你检查你的屏幕截图,图是正确的。绘制的第一个条非常高,其他剩余值(符合您的预期)接近1x10^3波段。您的直方图[]
数组很可能是用错误的数据初始化的,或者索引[0]
处的错误数据
我只能从代码和数据的这一侧推测at直方图[0]
中的值的重要性,但可能您正在接收一个数组,该数组包含索引[0]
中所有剩余数据的总和
作为预期的快速检查,如果您将循环更改为从索引[1]
开始,而不是从[0]
开始,您将看到所使用的绘图控件将正确执行预期在1x10^3频带附近的所有其他值,您应该检查填充直方图的数据源,查看第一个数据点是否相关或设置为错误值
for (int i = 1; i < histogram.Length; i++)
{
double x = (double)i + 1;
//double y = (double)i + 1;//rand.NextDouble() * 1000;
double z = i / 4.0;
list.Add(x, histogram[i], z);
}
for(int i=1;i
我认为这更多地与您的列表的表示有关,您在其中绘制条形图。在BarItem myCurve=myPane.AddBar(
并查看list
nawfal我做了什么。我看到的是:在索引0的列表中,我看到:{(134118)}在索引1中,我看到{(21251)}等等,直到256。我在我的问题中添加了一个图像,关于ZedGraph的外观。这些值非常高。如果你不能将其复制到图形中,那么问题在于你在哪里绘制它,不是吗?我不确定nawfal的问题出在哪里。