2

I would like to use FSharpChart but there is no basic Chart for what I would like to display : a correlation matrix.

I therefore wrote some functions to draw on a bitmap, along the way that Tomas Petricek does for charting a pie-chart.

Is there any easy way for me to use this to extend FSharpChart ?

let drawCorrelation (udls:seq<'T>) (mapcorrel:Map<('T*'T), float>)  = 
      let mainForm = new Form(Width = 1250, Height = 1050, Text = "Correlation matrix")
      let boxChart = new PictureBox(BackColor = Color.White, Dock = DockStyle.Fill,SizeMode = PictureBoxSizeMode.CenterImage)

      let matrixbm  = new Bitmap(1200, 1000)
      let gr = Graphics.FromImage(matrixbm)

      gr.Clear(Color.White)
      draw2D  gr (drawCorrelationInner mapcorrel) 1200 1000 udls mapcorrel (mapcorrel |> Seq.map (fun kv -> kv.Value ) |> Seq.average)

      boxChart.Image <- matrixbm
      mainForm.Controls.Add(boxChart)
      mainForm.Show()
4
  • I'm not entirely sure what kind of chart would you like to get. Something like this: 2.bp.blogspot.com/_VCI4AaOLs-A/SG5DdrcvViI/AAAAAAAAAJA/… (to display pairwise correlations between things) or something like this en.wikipedia.org/wiki/File:Anscombe%27s_quartet_3.svg (to display corelation between a series and a linear regression)? Mar 19, 2012 at 16:01
  • This is exactly the pairwise correlation that I am trying to display. I found that your article on charting in MSDN deal with the underlying Chart Controls. I should probably get more familiar with them.
    – nicolas
    Mar 19, 2012 at 16:03
  • (actually, the inverse of the covariance matrix is better to display relationship, as it revelas conditional independance, but from a graphing perspective it is the same)
    – nicolas
    Mar 19, 2012 at 16:05
  • I'm afraid there is no way to easily compose that kind of things using FSharpChart. The Chart Controls don't have any basic chart that you could adapt for this purpose, so drawing it using WinForms (or WPF) is probably the only option. Mar 19, 2012 at 16:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.