dcsimg
Results 1 to 3 of 3

Thread: BoxPlot Chart issue

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2016
    Location
    Perth Australia
    Posts
    41

    BoxPlot Chart issue

    I have had success in adding a succession of points to a scatterplot type chart using Visual Basic coding. This is via the command Chart.Series("MySeries").Points.AddXY(MyX, MyY). The issue at present is that I have an array that contains my data values to be added for a BoxPlot type chart (these are 50m freestyle race times to be displayed in a boxplot chart).

    The series called "50m Free" already exists within the Chart called Ch2 and I have the data Series called "50m Free" set as a BoxPlot chartype (at design time not run time).

    Currently I am using the following code ... the code runs without any errors/exceptions but shown below is what I get from the chart:

    Code:
    With ch2.Series("50m Free")
                .Points.Clear()
                For i = 1 To ArraySize
                    .Points.Add(ThisArray(i))
                Next
    
            End With
    Name:  chart.png
Views: 131
Size:  4.5 KB

    Any ideas on what is wrong OR some setting at design time within the Chart properties ?
    Any thoughts are appreciated.

  2. #2
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    410

    Re: BoxPlot Chart issue

    Keep in mind the box chart is an average box of points. In this example there is one box chart series drawn (light blue box with vert line and red points) and one series of points (tan color) for the box chart. The box shows the percentile range specified for the dataseries values.

    Your example has the datapoint series but not the box chart series drawn.

    What do you want to see? Are you doing this for a purpose or because you were told make a box chart?

    Do you want to see averages for each swimmer where each swimmer has multiple races? Then you need to make a multiple race times dataseries and a box chart for each swimmer? This example has one swimmer.


    Name:  a.png
Views: 26
Size:  14.3 KB

    Code:
    Imports System.Windows.Forms.DataVisualization.Charting
    
    Public Class Form3
        Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            With Chart1.ChartAreas(0)
                .AxisX.Title = "Point"
                .AxisX.MajorGrid.Enabled = False
                .AxisY.Title = "Value"
                .AxisY.MajorGrid.LineColor = Color.Gray
            End With
    
    
            With Chart1.Series(0)
                .Name = "BoxPlotSeries"
                .ChartType = SeriesChartType.BoxPlot
                .MarkerColor = Color.Red
                .Color = Color.SkyBlue
                .MarkerSize = 6
            End With
    
            Chart1.Series.Add("DataSeries")
            With Chart1.Series(1)
                .ChartType = SeriesChartType.Point
                .Color = Color.Tan
            End With
    
            ' Populate series data
            Dim yValues As Double() = {55.62, 45.54, 73.45, 73, 88.42, 45.9, 63.6, 85.1, 67.2, 60}
            Chart1.Series("DataSeries").Points.DataBindY(yValues)
    
            ' Specify data series name for the Box Plot
            Chart1.Series("BoxPlotSeries")("BoxPlotSeries") = "DataSeries"
    
            ' Set whiskers percentile
            Chart1.Series("BoxPlotSeries")("BoxPlotWhiskerPercentile") = "5"
    
            ' Set box percentile
            Chart1.Series("BoxPlotSeries")("BoxPlotPercentile") = "30"
    
            ' Hide Average line
            Chart1.Series("BoxPlotSeries")("BoxPlotShowAverage") = "true"
    
            ' Show/Hide Median line
            Chart1.Series("BoxPlotSeries")("BoxPlotShowMedian") = "true"
    
            ' Show Unusual points
            Chart1.Series("BoxPlotSeries")("BoxPlotShowUnusualValues") = "true"
    
        End Sub
    End Class

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2016
    Location
    Perth Australia
    Posts
    41

    Re: BoxPlot Chart issue

    Quote Originally Posted by tommytwotrain View Post
    Keep in mind the box chart is an average box of points. In this example there is one box chart series drawn (light blue box with vert line and red points) and one series of points (tan color) for the box chart. The box shows the percentile range specified for the dataseries values.

    Your example has the datapoint series but not the box chart series drawn.

    What do you want to see? Are you doing this for a purpose or because you were told make a box chart?

    Do you want to see averages for each swimmer where each swimmer has multiple races? Then you need to make a multiple race times dataseries and a box chart for each swimmer? This example has one swimmer.


    Name:  a.png
Views: 26
Size:  14.3 KB

    Code:
    Imports System.Windows.Forms.DataVisualization.Charting
    
    Public Class Form3
        Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            With Chart1.ChartAreas(0)
                .AxisX.Title = "Point"
                .AxisX.MajorGrid.Enabled = False
                .AxisY.Title = "Value"
                .AxisY.MajorGrid.LineColor = Color.Gray
            End With
    
    
            With Chart1.Series(0)
                .Name = "BoxPlotSeries"
                .ChartType = SeriesChartType.BoxPlot
                .MarkerColor = Color.Red
                .Color = Color.SkyBlue
                .MarkerSize = 6
            End With
    
            Chart1.Series.Add("DataSeries")
            With Chart1.Series(1)
                .ChartType = SeriesChartType.Point
                .Color = Color.Tan
            End With
    
            ' Populate series data
            Dim yValues As Double() = {55.62, 45.54, 73.45, 73, 88.42, 45.9, 63.6, 85.1, 67.2, 60}
            Chart1.Series("DataSeries").Points.DataBindY(yValues)
    
            ' Specify data series name for the Box Plot
            Chart1.Series("BoxPlotSeries")("BoxPlotSeries") = "DataSeries"
    
            ' Set whiskers percentile
            Chart1.Series("BoxPlotSeries")("BoxPlotWhiskerPercentile") = "5"
    
            ' Set box percentile
            Chart1.Series("BoxPlotSeries")("BoxPlotPercentile") = "30"
    
            ' Hide Average line
            Chart1.Series("BoxPlotSeries")("BoxPlotShowAverage") = "true"
    
            ' Show/Hide Median line
            Chart1.Series("BoxPlotSeries")("BoxPlotShowMedian") = "true"
    
            ' Show Unusual points
            Chart1.Series("BoxPlotSeries")("BoxPlotShowUnusualValues") = "true"
    
        End Sub
    End Class
    I have my values in an Array called ThisArray and I want to see a box and whisker plot that shows the maximum and minimum values, the upper and lower quartiles and the median etc. I am not able to store the values as you have indicated in:

    Dim yValues As Double() = {55.62, 45.54, 73.45, 73, 88.42, 45.9, 63.6, 85.1, 67.2, 60}

    Hope this clarifies what I want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width