| ||
General Tutorials Style Examples SharpLeaf Tutorials Document Layout Tutorials Text Flow Tutorials Table Tutorials Visual Glossaries SharpPlot Reference SharpPlot Class SharpPlot Properties SharpPlot Methods SharpPlot Structures SharpPlot Enumerations PageMap Class SharpLeaf Reference SharpLeaf Class SharpLeaf Properties SharpLeaf Methods Table Class Table Properties Table Methods SharpLeaf Structures FontType Structure ParagraphStyle Structure BoxStyle Structure SharpLeaf Enumerations DocumentLayout Classes DocumentLayout Class PageLayout Class PageElement Abstract Class Frame : PageElement Class TextBlock : PageElement Class ImageBlock : PageElement Class Box : PageElement Class Rule : PageElement Class Common Reference Document Class VectorMath Class DbUtil Class Download Release Notes Licensing |
SharpPlot Tutorials > Chart Samples > Bubble charts for discrete XYZ data Bubble charts for discrete XYZ dataThis tutorial builds four simple examples of bubble-charts, showing how the markers scale to represent an extra dimension in the data. Regression models may be used with the bubble-chart – naturally the area of the bubble weights the model-fit appropriately. User-defined markers can be used to good effect also, as the final example illustrates. A Simple Weighted ScatterThis is the most obvious use of the bubblechart. Three vectors of data are provided, giving the x,y co-ordinates of each value and a count of the number of items at that point. ydata = new int[] {190,270,310,120,190,230}; xdata = new int[] {17,31,29,14,16,24}; count = new int[] {12,65,77,7,9,112}; sp.Heading = "Incident count"; sp.SetXTickMarks(5); sp.SetYTickMarks(50); sp.SetMarkers(Marker.Bullet); sp.SetMarkerScales(5); sp.BubbleChartStyle = BubbleChartStyles.GridLines|BubbleChartStyles.ValueTags; sp.SetValueTags(count); sp.SetValueFont("Arial",10); sp.DrawBubbleChart(ydata,xdata,count); sp.SetKeyText("Number of Incidents"); Note that this chart adds Value tags to the markers to give an exact value for the count at that point. Two categories, to compare seriesThis chart shows data collected from two similar experiments, and allows a quick comparison of the success of each (maybe the number of seeds which germinated under gven lighting and temperature). ydata = new int[] {190,270,310,120,190,230,200,240,311,110}; xdata = new int[] {17,31,29,14,16,24,19,24,30,12}; count = new int[] {12,65,77,7,9,112,18,194,90,17}; type = new int[] {1,1,1,1,1,1,2,2,2,2}; sp.Heading = "Two Experiments Compared"; sp.SetMarkers(Marker.Bullet); sp.SetMarkerScales(5); sp.SetColors(new Color[] {Color.Orange,ColorTranslator.FromHtml("#80006666")}); sp.BubbleChartStyle = BubbleChartStyles.GridLines|BubbleChartStyles.ExplodeAxes; sp.SetKeyText(new string[]{"Old method","New method"}); sp.SplitBy(type); sp.DrawBubbleChart(ydata,xdata,count); Note that the axes are ‘exploded’ here to keep them out of the way of the data. Note also the use of semi-transparent markers to avoid the second series obscuring results from the first. Weighted modelfitThis example illustrates the way the regression line is weighted by the count at each data-point. ydata = new int[] {190,270,310,120,190,230}; xdata = new int[] {17,31,29,14,16,24}; count = new int[] {12,15,77,97,9,112}; sp.Heading = "Weighted Regression"; sp.SetYTickMarks(50); sp.SetMarkers(Marker.Lozenge); sp.SetMarkerScales(5); sp.BubbleChartStyle = BubbleChartStyles.GridLines|BubbleChartStyles.ModelFit| BubbleChartStyles.HaloMarkers; sp.DrawBubbleChart(ydata,xdata,count); sp.SetKeyText(new string[]{"Incident count","Weighted model"}); You can see that the fitted line is strongly biased towards the points with more data. User-defined Markers showing categoriesThis example exploits two standard WingDings characters to show the number of contacts by phone and mail. ydata = new int[] {190,270,310,120,190,230,200,240,311,110}; xdata = new int[] {17,31,29,14,16,23,19,24,30,12}; count = new int[] {12,65,77,7,9,112,18,194,90,17}; type = new int[] {1,1,1,1,1,1,2,2,2,2}; sp.Heading = "User-defined Markers"; sp.SetColors(new Color[]{Color.Orange,Color.Purple}); // Telephone and Letter symbols sp.SetMarkers(new Marker[]{(new Marker("wingdings,9,)")),new Marker("wingdings,9,+")}); sp.SetMarkerScales(5); sp.BubbleChartStyle = BubbleChartStyles.GridLines|BubbleChartStyles.ExplodeAxes; sp.SplitBy(type); sp.DrawBubbleChart(ydata,xdata,count); sp.SetKeyText(new string[]{"Contacts by Phone","Contacts by Letter"}); Note that there is no need to have the markers drawn semi-transparently here as they are only drawn in outline. Several other characters in the WingDings font are extremely useful for categorised data, for example the circled numbers may be used to represent up to 20 categories very effectively. SummaryThe Bubblechart is an effective way of combining dimensions where you need to show how many events occurred at a particular combination of X and Y values (such as the number of artifacts found in each grid square on a field survey). Transparency can be used effectively where there are many overlapping bubbles. |