This is a migrated thread and some comments may be shown as answers.

Plotting error bars (x-y) on a scatter plot

3 Answers 115 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Nicolò
Top achievements
Rank 1
Nicolò asked on 20 Jan 2021, 02:33 PM

Hi,

I am using RadChartView to plot a series of points. For each of these points I have a x and y coordinate as well as a standard deviation of the  measurements (each point is in fact a collection of measurements). How can I plot the error bars?

I saw this post explaining the procedure for wpf but I cant find a parallel way of doing it in winforms

https://www.telerik.com/blogs/how-to-create-scatter-error-bars-and-box-plot-series-with-radchart-for-sl-wpf

Sorry for not providing a starting point but I really have no clue of where to start from 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Jan 2021, 02:46 PM
    

Hello, Nicolò, 

I would like to note that RadChartView from the Telerik UI for WinForms suite and the WPF suite are two different controls and they have different internal implementation considering the platform specifics.

Since according to the provided information, it is not quite clear what is the exact data that you have for populating the chart, it wouldn't easy to provide the most appropriate solution for you. Could you please elaborate?

However, I will try to give some suggestions that I suppose that may be applicable for your scenario.

RadChartView introduces support for stock series – both Ohlc (Open-High-Low-Close) and Candlestick. These series operate with special data points which hold information about each the following parameters: open, high, low, close: https://docs.telerik.com/devtools/winforms/controls/chartview/series-types/ohlc-and-candlestick

The Hlc series is a simple variant of the Ohlc series which was discussed in the previous topic. Its data points contain information about the following parameters: * high, *low and close: https://docs.telerik.com/devtools/winforms/controls/chartview/series-types/hlc

RadChartView uses Linear axes to plot data containing numerical values: https://docs.telerik.com/devtools/winforms/controls/chartview/axes/linear#linear 

You can combine OhlcSeries and LineSeries with numeric category to simulate plotting data points over the Ohlc series: 

            OhlcSeries ohlcSeries = new OhlcSeries(); 
            ohlcSeries.DataPoints.Add(new OhlcDataPoint(10, 11, 7, 8, 1));
            ohlcSeries.DataPoints.Add(new OhlcDataPoint(8, 9, 5, 9, 2));
            ohlcSeries.DataPoints.Add(new OhlcDataPoint(12, 12, 9, 10, 3));
            ohlcSeries.DataPoints.Add(new OhlcDataPoint(7, 10, 6, 9, 4));
            
            LineSeries scatterSeries = new LineSeries();
            scatterSeries.BorderColor = Color.Transparent;
            scatterSeries.DataPoints.Add(new CategoricalDataPoint(9,1));
            scatterSeries.DataPoints.Add(new CategoricalDataPoint(6,2));
            scatterSeries.DataPoints.Add(new CategoricalDataPoint(10,3));
            scatterSeries.DataPoints.Add(new CategoricalDataPoint(8,4)); 
            scatterSeries.PointSize = new SizeF(10,10);
           
            this.radChartView1.Series.Add(ohlcSeries);
            this.radChartView1.Series.Add(scatterSeries);

If none of the defaults series types is applicable for your case, you can create a custom cartesian renderer and implement your own logic for rendering the points. A sample example is demonstrated here:

https://docs.telerik.com/devtools/winforms/controls/chartview/customization/custom-rendering

https://www.telerik.com/forums/are-stepline-charts-supported-with-the-winforms-chartview-control#A4t58Cla7EqvZkpq9QlHpw 

Note that each series has its own specific DrawPart. Even though the above referred articles demonstrates a sample approach for the LineSeriesDrawPart, you can download the source code from your Telerik account and have a look at the default implementation of the DrawParts of the other series. Then, following a similar approach, you can replace the default DrawPart with your custom one: https://docs.telerik.com/devtools/winforms/knowledge-base/attach-telerik-source-code-to-your-project

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Nicolò
Top achievements
Rank 1
answered on 22 Jan 2021, 03:47 PM

Thanks for the answer I'll take a look at the DrawParts for the scatter and try and make it work. The candle is similar but not exactly enough.
I'll try to explain my situation better and attach an image of a graph as example. 

Each point has 4 numbers , the x coordinate(x), the y coordinate(y), the uncertainty on the x coordinate (ux) and the uncertainty on the y coordinate(uy). The result is a dot on (x,y), then a horizontal line centered in the dot (x,y) with a width of 2*(ux), and a vertical line centered in (x,y) with a height of 2*(uy)

0
Hristo
Telerik team
answered on 26 Jan 2021, 01:33 PM

Hi Nicolò,

Thanks for the clarifications. Indeed, the HLC and OHLC series serve a different purpose and they are not suitable for you actual scenario. As my colleague also noted it will be necessary to use a custom renderer. I`ve created a sample project demonstrating a possible solution. Besides a custom renderer, I am using special scatter data points holding information about the deviations along the X and Y axes. Here is a screenshot of the result: 

I hope that the attached project would fit your local setup. Please note, however, that this custom implementation may not handle all possible cases. 

Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ChartView
Asked by
Nicolò
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Nicolò
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or