Hi Alia,
The CWGraph in MStudio displays the Histogram with every point/value on the top right corner of the bar.
You already know this but just to explain a little bit more: any rectangle (bar in histogram) has four corners. When looking at that rectangle/bar in the Histogram (graph) one can define 4 corners as top-left, top-right, bottom-left, and bottom-right.
So, in this case every value of the histogram bar is on the top right. Thus for the first value if it is larger than the second value, you see a line and miss the bar. To fix the problem you can look at the function below. This function code will modify your histogram data to display it properly. You can include this code in your program and call the function before calling PlotXvsY.
void FormatData(CNiReal64Vector &axis,CNiIntVector &histogram,CNiReal64Vector &newaxis, CNiIntVector &newHistogram)
{
int axisLenght = axis.GetSize();
int histogramLenght = histogram.GetSize();
double binWidth = 1;
double halfBinWidth = 0.5;
if( (axisLenght<1) || (histogramLenght<1) )
return;
binWidth = abs( (double)(axis[0] - axis[1]) );
halfBinWidth = binWidth/2.0;
newaxis.SetSize(axisLenght+1);
newHistogram.SetSize(axisLenght+1);
newaxis[0] = axis[0] - halfBinWidth;
newHistogram[0] = histogram[0];
for(int i =1; i<= axisLenght;i++)
{
newaxis[i] = axis[i-1] + halfBinWidth;
newHistogram[i] = histogram[i-1];
}
return;
}
Do let me know if you need more help,
Rajiv G
National Instruments