Jump to content
Software FX Community

Error Bars


scottvv
 Share

Recommended Posts

I wish to make a plot that contains one series of N data values.  The Y axis is numerical, the X axis is categorical.  I wish to make a scatter plot with error bars. 

Each of the N points has a Y value, and an associated error bar (uncertainty) value.  Both the Y and error bar values are retrieved from a database (in other words, the error bars are not calculated after the database query from a statistical study).  The query returns 3 fields - the categorical X value, the numerical Y value, and the numerical error bar value. 

For example, a Y value of 10, with an error bar value of 2.  The data i want passed to the chart will be the categorical X value, a Y value of 10, and an error bar value of 2.  The main point is that i want to pass the error bar value to the chart.  This means i want a marker (example, circle) at a Y value of 10, and a vertical error bar line going from 8 (10 - 2) to 12 (10 + 2). 

Using Microsoft Excel, this is easy.  I can just populate 3 columns that contain the X value, Y value, and error bar value, and then set the appropriate column to represent Y error bars. 

Can i accomplish this with ChartFX?  I am hoping so, but have not figured it out so far.  Any help?

Link to comment
Share on other sites

 My code has the following to specify the X categorical values and the Y numerical values. 

chart.DataSourceSettings.Fields.Add(new FieldMap("CollectionDate", FieldUsage.Label));

chart.DataSourceSettings.Fields.Add(

new FieldMap("Result", FieldUsage.Value));

 

I was anticipating their might be a FieldUsage.YErrorBar property that i could use. 

Link to comment
Share on other sites

Just to be even more clear, go to the SoftwareFX home page, click on Chart Gallery, scroll down to Statistical Charts, and find the chart labeled Scatter with Error Bar Chart.  This is what i want to make.  But i want the low-Y value and high-Y value of the vertical error bar line (in other words, the Y value range of the error bar) for each point to be passed into the chart along with the X and Y values of the data point. 

Link to comment
Share on other sites

I understand exactly what you want.

The error bar in the statistical extension won't work for you as they are equal for all the points.

What you can do is create a bar chart combined with a scatter chart to achieve this.

Using data binding you will do something like this:

chart.DataSourceSettings.Fields.Add(new FieldMap("CollectionDate", FieldUsage.Label));

chart.DataSourceSettings.Fields.Add(

new FieldMap("Result", FieldUsage.Value)); // This is your scatter point

chart.DataSourceSettings.Fields.Add(new FieldMap("LowValue", FieldUsage.FromValue)); // This is your low value for the error bar

chart.DataSourceSettings.Fields.Add(new FieldMap("HighValue", FieldUsage.Value)); // This is your low value for the error bar

 Then you show the chart using a combination of Scatter and Bars:

chart1.Series[0].Gallery = Gallery.Scatter;

chart1.Series[1].Gallery =

Gallery.Bar;

You can make the bars thin by doing:

chart1.Series[1].Volume = 1;

 

Link to comment
Share on other sites

Thank you for the help.  Your suggestion does end up making the error bar from my data source.  The only problem is that the error bars are slightly offset along the X axis from the center of the primary data points.  In other words, the points in series[0] and the bars in series[1] are not positioned at the exact same X axis value.  I have looked and experimented with trying to get the bars to go thru the center of the points, but have failed so far.  Is this possible? 

 I was thinking that if the X axis were numerical instead of categorical, then maybe each series would show up at the exact same X value, but the fact is that my X axis is categorical. 

 

Link to comment
Share on other sites

Looks like we are doing something different. This is not what I get with the code I posted. My bars are perfectly centered with the points. I think you may have an extra series in your chart. Tour on the DataGrid (chart.DataGrid.Visible = true) to verify.

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...