Example 137: Scientific Graph showing Error Bars

PesgoScientific Graph Objectintermediate

Error Bars

Preview

ProEssentials Pesgo Scientific Graph Object - Scientific Graph showing Error Bars
Click to enlarge

Source Code

Form3.cs
1int c;
2double dRange;
3int p;
4
5float erroramount;
6erroramount = 2.5F; // erroramount = Error Bar Amount
7
8Pesgo1.PeData.Subsets = 1;
9Pesgo1.PeData.Points = 9;
10
11// Pass XData and YData //
12for (p = 0; p < 9; p++)
13{
14 Pesgo1.PeData.X[0, p] = (p + 1.0F) * 10.0F;
15 Pesgo1.PeData.Y[0, p] = (float)(25.0F + (Rand_Num.NextDouble() * 10.0F));
16}
17
18// This code shows how to learn axis range without having to perform a cpu intensive image build //
19// Do partial initialization, read axis extents to know how to adjust scales, and continue //
20Pesgo1.PeFunction.Reinitialize();
21dRange = Pesgo1.PeGrid.Configure.ManualMaxY - Pesgo1.PeGrid.Configure.ManualMinY;
22
23// Manually Control Y Axis as we learned extents above //
24Pesgo1.PeGrid.Configure.ManualScaleControlY = ManualScaleControl.MinMax;
25Pesgo1.PeGrid.Configure.ManualMinY = Pesgo1.PeGrid.Configure.ManualMinY - erroramount - (dRange * 0.1F);
26Pesgo1.PeGrid.Configure.ManualMaxY = Pesgo1.PeGrid.Configure.ManualMaxY + erroramount + (dRange * 0.1F);
27
28// Set Plotting Style and Comparison Subsets //
29Pesgo1.PePlot.Method = SGraphPlottingMethod.PointsPlusLine;
30Pesgo1.PePlot.PointSize = PointSize.Medium;
31Pesgo1.PePlot.Option.MinimumPointSize = MinimumPointSize.Large;
32Pesgo1.PeAnnotation.Graph.MinSymbolSize = MinimumPointSize.Large;
33
34// v9.5
35Pesgo1.PeUserInterface.Menu.AnnotationControl = true;
36
37// Adding dash symbols at each end of error bar //
38// along with line connecting dashes. //
39c = 0;
40for (p = 0; p < 9; p++)
41{
42 Pesgo1.PeAnnotation.Graph.X[c] = Pesgo1.PeData.X[0, p];
43 Pesgo1.PeAnnotation.Graph.Y[c] = Pesgo1.PeData.Y[0, p] + erroramount;
44 Pesgo1.PeAnnotation.Graph.Type[c] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.ThinSolidLine;
45 Pesgo1.PeAnnotation.Graph.Color[c] = Color.FromArgb(255, 255, 0, 0);
46 Pesgo1.PeAnnotation.Graph.Text[c] = "";
47 c++;
48
49 Pesgo1.PeAnnotation.Graph.X[c] = Pesgo1.PeData.X[0, p];
50 Pesgo1.PeAnnotation.Graph.Y[c] = Pesgo1.PeData.Y[0, p] - erroramount;
51 Pesgo1.PeAnnotation.Graph.Type[c] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.LineContinue;
52 Pesgo1.PeAnnotation.Graph.Color[c] = Color.FromArgb(255, 255, 0, 0);
53 Pesgo1.PeAnnotation.Graph.Text[c] = "";
54 c++;
55
56 Pesgo1.PeAnnotation.Graph.X[c] = Pesgo1.PeData.X[0, p];
57 Pesgo1.PeAnnotation.Graph.Y[c] = Pesgo1.PeData.Y[0, p] + erroramount;
58 Pesgo1.PeAnnotation.Graph.Type[c] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.Dash;
59 Pesgo1.PeAnnotation.Graph.Color[c] = Color.FromArgb(255, 0, 255, 255);
60 Pesgo1.PeAnnotation.Graph.Text[c] = "";
61 c++;
62
63 Pesgo1.PeAnnotation.Graph.X[c] = Pesgo1.PeData.X[0, p];
64 Pesgo1.PeAnnotation.Graph.Y[c] = Pesgo1.PeData.Y[0, p] - erroramount;
65 Pesgo1.PeAnnotation.Graph.Type[c] = (int)Gigasoft.ProEssentials.Enums.GraphAnnotationType.Dash;
66 Pesgo1.PeAnnotation.Graph.Color[c] = Color.FromArgb(255, 0, 255, 255);
67 Pesgo1.PeAnnotation.Graph.Text[c] = "";
68 c++;
69}
70
71Pesgo1.PeAnnotation.Show = true;
72Pesgo1.PeAnnotation.InFront = false;
73
74// Subset colors //
75Pesgo1.PeColor.SubsetColors[0] = Color.FromArgb(225, 255, 215, 19);
76
77// Set Line Styles //
78Pesgo1.PePlot.SubsetLineTypes[0] = LineType.MediumSolid;
79
80// Allow zooming and panning //
81Pesgo1.PeUserInterface.Allow.Zooming = AllowZooming.Horizontal;
82Pesgo1.PeUserInterface.Scrollbar.ScrollingHorzZoom = true;
83Pesgo1.PeUserInterface.Scrollbar.ScrollingScaleControl = true;
84
85// Set Various Other Properties //
86Pesgo1.PeColor.BitmapGradientMode = true;
87Pesgo1.PeColor.QuickStyle = QuickStyle.DarkInset;
88Pesgo1.PeUserInterface.Allow.FocalRect = false;
89Pesgo1.PeUserInterface.Allow.ZoomStyle = ZoomStyle.Ro2Not;
90Pesgo1.PeFont.Fixed = true;
91Pesgo1.PeConfigure.PrepareImages = true;
92Pesgo1.PeConfigure.CacheBmp = true;
93Pesgo1.PeConfigure.TextShadows = TextShadows.BoldText;
94Pesgo1.PeFont.MainTitle.Bold = true;
95Pesgo1.PeFont.SubTitle.Bold = true;
96Pesgo1.PeFont.Label.Bold = true;
97Pesgo1.PePlot.Option.LineShadows = true;
98Pesgo1.PeFont.FontSize = FontSize.Medium;
99Pesgo1.PeGrid.Configure.AutoMinMaxPaddingX = 5;
100Pesgo1.PeGrid.Configure.AutoMinMaxPaddingY = 40;
101Pesgo1.PeGrid.LineControl = GridLineControl.None;
102
103Pesgo1.PeString.MainTitle = "Error Bars via Graph Annotations";
104Pesgo1.PeString.SubTitle = "";
105
106// Set various export defaults //
107Pesgo1.PeSpecial.DpiX = 600;
108Pesgo1.PeSpecial.DpiY = 600;
109
110// default export setting //
111Pesgo1.PeUserInterface.Dialog.ExportSizeDef = ExportSizeDef.NoSizeOrPixel;
112Pesgo1.PeUserInterface.Dialog.ExportTypeDef = ExportTypeDef.Png;
113Pesgo1.PeUserInterface.Dialog.ExportDestDef = ExportDestDef.Clipboard;
114Pesgo1.PeUserInterface.Dialog.ExportUnitXDef = "1280";
115Pesgo1.PeUserInterface.Dialog.ExportUnitYDef = "768";
116Pesgo1.PeUserInterface.Dialog.ExportImageDpi = 300;
117
118Pesgo1.PeConfigure.RenderEngine = RenderEngine.Direct2D;
119Pesgo1.PeConfigure.AntiAliasGraphics = true;
120Pesgo1.PeConfigure.AntiAliasText = true;
121
122// Generally call ReinitializeResetImage at end **'
123Pesgo1.PeFunction.ReinitializeResetImage();
124Pesgo1.Invalidate();
125// Optionally call Pesgo1.Refresh() if you are not seeing changes immediately
Tip: Uses property syntax like Pego1.PeData.Y[s, p]Click underlined properties to view documentation