<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>VB.NET charts Archives - CenterSpace</title>
	<atom:link href="https://www.centerspace.net/tag/vb-net-charts/feed" rel="self" type="application/rss+xml" />
	<link>https://www.centerspace.net/tag/vb-net-charts</link>
	<description>.NET numerical class libraries</description>
	<lastBuildDate>Tue, 07 Feb 2023 21:30:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
<site xmlns="com-wordpress:feed-additions:1">104092929</site>	<item>
		<title>The Importance of Graphing Your Data</title>
		<link>https://www.centerspace.net/the-importance-of-graphing-your-data</link>
					<comments>https://www.centerspace.net/the-importance-of-graphing-your-data#respond</comments>
		
		<dc:creator><![CDATA[Ken Baldwin]]></dc:creator>
		<pubDate>Tue, 13 Dec 2011 17:28:10 +0000</pubDate>
				<category><![CDATA[NMath]]></category>
		<category><![CDATA[NMath Stats]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[.NET charting]]></category>
		<category><![CDATA[.NET plotting]]></category>
		<category><![CDATA[C# charts]]></category>
		<category><![CDATA[C# ploting]]></category>
		<category><![CDATA[Chart Controls for .NET]]></category>
		<category><![CDATA[F# charts]]></category>
		<category><![CDATA[VB.NET charts]]></category>
		<category><![CDATA[VB.NET plotting]]></category>
		<guid isPermaLink="false">http://www.centerspace.net/blog/?p=3639</guid>

					<description><![CDATA[<p><img class="excerpt" title="Anscombe's Quartet" src="https://www.centerspace.net/blog/wp-content/uploads/2011/12/anscombe2.png" alt="Anscombe's Quartet" /><br />
In his classic book <em>The Visual Display of Quantitative Information</em>, Edward R. Tufte argued that "graphics can be more precise and revealing than conventional statistical computations".  As an example, he described <a href="http://en.wikipedia.org/wiki/Anscombe%27s_quartet">Anscombe's Quartet</a>--four datasets that have identical simple statistical properties, yet appear very different when graphed.</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/the-importance-of-graphing-your-data">The Importance of Graphing Your Data</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In his classic book <em>The Visual Display of Quantitative Information</em>, Edward R. Tufte argued that &#8220;graphics can be more precise and revealing than conventional statistical computations&#8221;. As an example, he described <a href="https://en.wikipedia.org/wiki/Anscombe%27s_quartet">Anscombe&#8217;s Quartet</a>&#8211;four datasets that have identical simple statistical properties, yet appear very different when graphed.<br />
<a href="https://www.centerspace.net/blog/wp-content/uploads/2011/12/anscombe2.png"><img decoding="async" class="aligncenter size-full wp-image-3655" title="Anscombe's Quartet" src="https://www.centerspace.net/blog/wp-content/uploads/2011/12/anscombe2.png" alt="Anscombe's Quartet" width="451" height="283" srcset="https://www.centerspace.net/wp-content/uploads/2011/12/anscombe2.png 451w, https://www.centerspace.net/wp-content/uploads/2011/12/anscombe2-300x188.png 300w" sizes="(max-width: 451px) 100vw, 451px" /></a><br />
These data sets&#8211;each consisting of 11 x,y points&#8211;were constructed by statistician Francis Anscombe in 1973.</p>
<p>As <a href="https://www.centerspace.net/nmath-charts-in-wpf/">previously described</a>, <strong>NMath 5.1</strong> and <strong>NMath Stats 3.4</strong> include classes for plotting NMath types using the Microsoft Chart Controls for .NET. (<a href="/nmath-integration-with-essential-chart/">Free adapter code</a> is also available for using NMath with Syncfusion Essential Chart.) Let&#8217;s use Anscombe&#8217;s data to explore how NMath&#8217;s new visualization capabilities can be used to reveal the differences in the data sets.</p>
<p>First, we&#8217;ll load the data into a <strong>DoubleMatrix</strong>.</p>
<pre lang="csharp">DoubleMatrix A = new DoubleMatrix( @"11x8 [
  10.0 8.04  10.0 9.14 10.0 7.46  8.0  6.58
  8.0  6.95  8.0  8.14 8.0  6.77  8.0  5.76
  13.0 7.58  13.0 8.74 13.0 12.74 8.0  7.71
  9.0  8.81  9.0  8.77 9.0  7.11  8.0  8.84
  11.0 8.33  11.0 9.26 11.0 7.81  8.0  8.47
  14.0 9.96  14.0 8.10 14.0 8.84  8.0  7.04
  6.0  7.24  6.0  6.13 6.0  6.08  8.0  5.25
  4.0  4.26  4.0  3.10 4.0  5.39  19.0 12.50
  12.0 10.84 12.0 9.13 12.0 8.15  8.0  5.56
  7.0  4.82  7.0  7.26 7.0  6.42  8.0  7.91
  5.0  5.68  5.0  4.74 5.0  5.73  8.0  6.89 ]" );</pre>
<p>Now let&#8217;s perform some simple descriptive statistics.</p>
<pre lang="csharp"> int groups = 4;
 Slice rows = Slice.All;
 Slice xCols = new Slice( 0, groups, 2 );
 Slice yCols = new Slice( 1, groups, 2 );
 double unbiased = (double)A.Rows / ( A.Rows - 1 );

 Console.WriteLine( "Mean of x: {0}",
   NMathFunctions.Mean( A[ rows, xCols ] ) );
 Console.WriteLine( "Variance of x: {0}",
   NMathFunctions.Variance( A[rows, xCols] ) * unbiased );
 Console.WriteLine( "Mean of y: {0}",
   NMathFunctions.Round( NMathFunctions.Mean( A[rows, yCols] ), 2 ) );
 Console.WriteLine( "Variance of y: {0}",
   NMathFunctions.Round(
     NMathFunctions.Variance( A[rows, yCols] ) * unbiased, 3 ) );

 Console.Write( "Correlation of x-y: " );
 for (int i = 0; i < A.Cols; i += 2 )
 {
   Console.Write( NMathFunctions.Round(
    StatsFunctions.Correlation( A.Col(i), A.Col(i + 1) ), 3 ) + " " );
 }
 Console.WriteLine();</pre>
<p>You can see from the output that the statistics are nearly identical for all four data sets:</p>
<pre class="code">Mean of x: [ 9 9 9 9 ]
Variance of x: [ 11 11 11 11 ]
Mean of y: [ 7.5 7.5 7.5 7.5 ]
Variance of y: [ 4.127 4.128 4.123 4.123 ]
Correlation of x-y: 0.816 0.816 0.816 0.817</pre>
<p>Now let's fit a linear model to each data set.</p>
<pre lang="csharp"> LinearRegression[] lrs = new LinearRegression[groups];

 for( int i = 0; i < groups; i ++ )
 {
   Console.WriteLine( "Group {0}", i + 1 );

   bool addIntercept = true;
   lrs[i] = new LinearRegression( new DoubleMatrix( A.Col( 2 * i ) ),
     A.Col( 2 * i + 1 ), addIntercept );
   Console.WriteLine( "equation of regression line: Y = {0} + {1}X",
     Math.Round( lrs[i].Parameters[0], 2 ),
     Math.Round( lrs[i].Parameters[1], 3 ) );

   LinearRegressionParameter param =
     new LinearRegressionParameter( lrs[i], 1 );
   Console.WriteLine( "standard error of estimate of slope: {0}",
     Math.Round( param.StandardError, 3 ) );
   Console.WriteLine( "t-statistic: {0}",
     Math.Round( param.TStatistic( 0 ), 2 ) );

   LinearRegressionAnova anova = new LinearRegressionAnova( lrs[i] );
   Console.WriteLine( "regression sum of squares: {0}",
     Math.Round( anova.RegressionSumOfSquares, 2 ) );
   Console.WriteLine( "residual Sum of squares: {0}",
     Math.Round( anova.ResidualSumOfSquares, 2 ) );
   Console.WriteLine( "r2: {0}", Math.Round( anova.RSquared, 2 ) );

   Console.WriteLine();
 }</pre>
<p>Again, the output is nearly identical for each data set:</p>
<pre class="code">Group 1
equation of regression line: Y = 3 + 0.5X
standard error of estimate of slope: 0.118
t-statistic: 4.24
regression sum of squares: 27.51
residual Sum of squares: 13.76
r2: 0.67

Group 2
equation of regression line: Y = 3 + 0.5X
standard error of estimate of slope: 0.118
t-statistic: 4.24
regression sum of squares: 27.5
residual Sum of squares: 13.78
r2: 0.67

Group 3
equation of regression line: Y = 3 + 0.5X
standard error of estimate of slope: 0.118
t-statistic: 4.24
regression sum of squares: 27.47
residual Sum of squares: 13.76
r2: 0.67

Group 4
equation of regression line: Y = 3 + 0.5X
standard error of estimate of slope: 0.118
t-statistic: 4.24
regression sum of squares: 27.49
residual Sum of squares: 13.74
r2: 0.67</pre>
<p>Finally, let's use the new <strong>NMath</strong> charting functionality to plot each linear regression fit. Note that we make use of the <code>Compose()</code> method to combine multiple charts into a single composite <strong>Chart</strong> control.</p>
<pre lang="csharp"> List<Chart> charts = new List<Chart>();
 for( int i = 0; i < lrs.Length; i++ )
 {
   charts.Add( NMathStatsChart.ToChart( lrs[i], 0 ) );
 }
 Chart all = NMathStatsChart.Compose( charts, 2, 2,
   NMathChart.AreaLayoutOrder.RowMajor );
 for( int i = 0; i < groups; i++ )
 {
   all.ChartAreas[i].AxisX.Title = "x" + ( i + 1 );
   all.ChartAreas[i].AxisX.Minimum = 2;
   all.ChartAreas[i].AxisX.Maximum = 22;
   all.ChartAreas[i].AxisX.Interval = 4;

   all.ChartAreas[i].AxisY.Title = "y" + ( i + 1 );
   all.ChartAreas[i].AxisY.Minimum = 2;
   all.ChartAreas[i].AxisY.Maximum = 14;
   all.ChartAreas[i].AxisY.Interval = 4;

   all.Series[2 * i].Color = Color.DarkOrange;
   all.Series[2 * i + 1].Color = Color.SteelBlue;
 }
 NMathStatsChart.Show( all );</pre>
<p><a href="https://www.centerspace.net/blog/wp-content/uploads/2011/12/anscombe.png"><img decoding="async" loading="lazy" class="aligncenter size-full wp-image-3640" title="Anscombe's Quartet" src="https://www.centerspace.net/blog/wp-content/uploads/2011/12/anscombe.png" alt="Anscombe's Quartet" width="497" height="499" srcset="https://www.centerspace.net/wp-content/uploads/2011/12/anscombe.png 497w, https://www.centerspace.net/wp-content/uploads/2011/12/anscombe-150x150.png 150w, https://www.centerspace.net/wp-content/uploads/2011/12/anscombe-298x300.png 298w" sizes="(max-width: 497px) 100vw, 497px" /></a>The charts reveal  dramatic differences between the data sets, despite the identical fitted models. Group 1 shows a linear relationship, while in Group 2 the releationship is clearly non-linear.  Groups 3 and 4 demonstrate how a single outlier can have a large effect on simple statistics.</p>
<p>Ken</p>
<p><strong>References</strong></p>
<p>Anscombe, F. J. (1973). "Graphs in Statistical Analysis". American Statistician 27 (1): 17–21. JSTOR 2682899.<br />
Tufte, Edward R. (2001). The Visual Display of Quantitative Information (2nd ed.). Cheshire, CT: Graphics Press</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/the-importance-of-graphing-your-data">The Importance of Graphing Your Data</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.centerspace.net/the-importance-of-graphing-your-data/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3639</post-id>	</item>
		<item>
		<title>.NET Math with Microsoft Chart Controls, Revisited</title>
		<link>https://www.centerspace.net/math-charts</link>
					<comments>https://www.centerspace.net/math-charts#comments</comments>
		
		<dc:creator><![CDATA[Ken Baldwin]]></dc:creator>
		<pubDate>Wed, 05 Oct 2011 18:28:35 +0000</pubDate>
				<category><![CDATA[NMath]]></category>
		<category><![CDATA[NMath Stats]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[.NET plotting]]></category>
		<category><![CDATA[C# ploting]]></category>
		<category><![CDATA[Chart Controls for .NET]]></category>
		<category><![CDATA[VB.NET charts]]></category>
		<category><![CDATA[VB.NET plotting]]></category>
		<guid isPermaLink="false">http://www.centerspace.net/blog/?p=3538</guid>

					<description><![CDATA[<p><img class="excerpt" title="Linear Regression Chart" src="https://www.centerspace.net/blog/wp-content/uploads/2011/09/lr.png" alt="Linear Regression Chart" /><br />
With the most recent releases of NMath 5.1 and NMath Stats 3.4, creating charts from our class types is easy with new adapter classes.  These classes use the .NET Microsoft Chart Controls for visualization, and allow for complex customization or simple data visualization with one line of code.  </p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/math-charts">.NET Math with Microsoft Chart Controls, Revisited</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Easy Math Charting</h3>
<p>In <a href="/using-nmath-with-microsoft-chart-controls-for-net/">an earlier post</a>, we described how NMath types can be plotted using the Microsoft Chart Controls for .NET, but programmatically constructing <strong>Chart</strong> objects with data series bound to NMath objects. The <a href="/new-versions-of-nmath-libraries-released-3/">latest release</a> of the NMath libraries makes this process much simpler by providing <em>adapter classes</em> which easily construct basic math charts for you from NMath types:</p>
<ul>
<li>NMath 5.1 includes assembly <strong>NMathChartMicrosoft.dll</strong> containing class <strong>NMathChart</strong>, which provides convenience methods for plotting NMath types using the Microsoft Chart Controls</li>
<li>NMath Stats 3.4 includes assembly <strong>NMathStatsChartMicrosoft.dll</strong> containing <strong>NMathStatsChart</strong> which provides convenience methods for plotting NMath Stats types using the Microsoft Chart Controls</li>
</ul>
<p>The generated charts can then be customized to meet your needs.</p>
<h3>Using the Math Chart Adapters</h3>
<p>The Microsoft Chart Controls for .NET are available as a <a href="https://www.microsoft.com/en-us/download/details.aspx?id=14422">separate download for .NET 3.5</a>. Beginning in .NET 4.0, the Chart controls are part of the .NET Framework. To use the Chart controls, add a reference to <code>System.Windows.Forms.DataVisualization</code>.<br />
To use the adapters, add a reference to <strong>NMathChartMicrosoft.dll</strong> and/or <strong>NMathStatsChartMicrosoft.dll,</strong> and <code>using</code> statement:</p>
<pre class="code">using CenterSpace.NMath.Charting.Microsoft;</pre>
<p>A <a href="/using-nmath-charts-with-net-4-0/">previous blog article</a> provides a simple <code>app.config</code> solution for deploying your chart dependent applications to target both .NET 3.5 or .NET 4.0.  Without this <code>app.config</code> modification, your application will only target .NET 3.5.</p>
<h3>The Math Chart Adapter API</h3>
<p>Both <strong>NMathChart</strong> and <strong>NMathStatsChart</strong> classes share a common API. Overloads of the <code>ToChart()</code> function are provided for our common math and stats types. <code>ToChart()</code> returns an instance of <code>System.Windows.Forms.DataVisualization.Charting.Chart</code>, which can be customized as desired. For example</p>
<pre lang="csharp">Polynomial poly = new Polynomial( new DoubleVector( 4, 2, 5, -2, 3 ) );
Chart chart = NMathChart.ToChart( poly, -1, 1 );
chart.Titles.Add("Hello World");</pre>
<p>For prototyping and debugging console applications, the <code>Show()</code> function shows a given chart in a default form.</p>
<pre lang="csharp">NMathChart.Show( chart );</pre>
<p>Note that when the window is closed, the chart is disposed.</p>
<p>If you do not need to customize the chart, overloads of <code>Show()</code> are also provided for common NMath types.</p>
<pre lang="csharp">NMathChart.Show( poly );</pre>
<p>This is equivalent to calling:</p>
<pre lang="csharp">NMathChart.Show( NMathChart.ToChart( poly ) );</pre>
<p>The <code>Save()</code> function saves a chart to a file or stream.</p>
<pre lang="csharp">NMathChart.Save( chart, "chart.png", ChartImageFormat.Png );</pre>
<p>If you are developing a Windows Forms application using the Designer, add a Microsoft Chart control to your form, then update it with an NMath object using the appropriate <code>Update()</code> function after initialization.</p>
<pre lang="csharp">public Form1()
{
  InitializeComponent();

  Polynomial poly =
    new Polynomial( new DoubleVector( 4, 2, 5, -2, 3 ) );
  NMathChart.Update( ref this.chart1, poly, -1, 1 );
}</pre>
<p>This has the following effect on your existing Chart object:</p>
<ul>
<li>a new, default ChartArea is added if one does not exist, otherwise chart.ChartAreas[0] is used</li>
<li>axis titles, and DefaultAxisTitleFont and DefaultMajorGridLineColor, only have an effect if a new ChartArea is added</li>
<li>titles are added only if the given Chart does not already contain any titles</li>
<li>chart.Series[0] is replaced, or added if necessary</li>
</ul>
<h3>Charting Examples</h3>
<p>Here are a few examples of usage in C# (Of course, as with all NMath functionality, these examples will also work, given the necessary syntactic changes, from VB.NET or F#, or any other .NET language.) :</p>
<pre lang="chsarp">double xmin = -1;
double xmax = 1;
int numInterpolatedValues = 100;
Polynomial poly = new Polynomial( new DoubleVector( 4, 2, 5, -2, 3 ) );
NMathChart.Show( poly, xmin, xmax, numInterpolatedValues );</pre>
<p><a href="https://www.centerspace.net/blog/wp-content/uploads/2011/09/polynomial.png"><img decoding="async" class="aligncenter size-full wp-image-3542" title="Polynomial" src="https://www.centerspace.net/blog/wp-content/uploads/2011/09/polynomial.png" alt="Math chart of a polynomial" width="480" srcset="https://www.centerspace.net/wp-content/uploads/2011/09/polynomial.png 489w, https://www.centerspace.net/wp-content/uploads/2011/09/polynomial-150x150.png 150w, https://www.centerspace.net/wp-content/uploads/2011/09/polynomial-300x300.png 300w" sizes="(max-width: 489px) 100vw, 489px" /></a></p>
<pre lang="csharp">DoubleVector x = new DoubleVector( 100, 0, 0.1 );
DoubleVector cos = x.Apply( NMathFunctions.CosFunction );
DoubleVector sin = x.Apply( NMathFunctions.SinFunction );

DoubleVector[] data = new DoubleVector[] { cos, sin };
NMathChart.Unit unit = new NMathChart.Unit( 0, 0.1, "x" );
Chart chart = NMathChart.ToChart( data, unit );

chart.Series[0].Name = "cos(x)";
chart.Series[1].Name = "sin(x)";
NMathChart.Show( chart );</pre>
<p><a href="https://www.centerspace.net/blog/wp-content/uploads/2011/09/vector_array.png"><img decoding="async" class="aligncenter size-full wp-image-3541" title="Vector Array" src="https://www.centerspace.net/blog/wp-content/uploads/2011/09/vector_array.png" alt="Math chart of a vector array" width="480" srcset="https://www.centerspace.net/wp-content/uploads/2011/09/vector_array.png 489w, https://www.centerspace.net/wp-content/uploads/2011/09/vector_array-150x150.png 150w, https://www.centerspace.net/wp-content/uploads/2011/09/vector_array-300x298.png 300w" sizes="(max-width: 489px) 100vw, 489px" /></a></p>
<pre lang="csharp">double lambda = 4.0;
PoissonDistribution poisson = new PoissonDistribution( lambda );

NMathStatsChart.Show( poisson,
  NMathStatsChart.DistributionFunction.PDF );</pre>
<p><a href="https://www.centerspace.net/blog/wp-content/uploads/2011/09/poisson_pdf1.png"><img decoding="async" class="aligncenter size-full wp-image-3544" title="Poisson Distribution" src="https://www.centerspace.net/blog/wp-content/uploads/2011/09/poisson_pdf1.png" alt="A math chart of a poisson distribution" width="480" srcset="https://www.centerspace.net/wp-content/uploads/2011/09/poisson_pdf1.png 487w, https://www.centerspace.net/wp-content/uploads/2011/09/poisson_pdf1-150x150.png 150w, https://www.centerspace.net/wp-content/uploads/2011/09/poisson_pdf1-298x300.png 298w" sizes="(max-width: 487px) 100vw, 487px" /></a></p>
<pre lang="csharp">DoubleMatrix predictors =
  new DoubleMatrix( 100, 3, new RandGenUniform() ); ;
DoubleVector observations = 2 * predictors.Col(0) +
  -0.75 * predictors.Col(1) + 1.25 * predictors.Col(2) + 0.5;
bool addIntercept = true;

LinearRegression lr =
  new LinearRegression( predictors, observations, addIntercept );
NMathStatsChart.Show( lr, 2 );</pre>
<pre class="csharp"><a href="https://www.centerspace.net/blog/wp-content/uploads/2011/09/lr.png"><img decoding="async" class="aligncenter size-full wp-image-3545" title="Linear Regression" src="https://www.centerspace.net/blog/wp-content/uploads/2011/09/lr.png" alt="Math chart of a linear regression" width="480" srcset="https://www.centerspace.net/wp-content/uploads/2011/09/lr.png 492w, https://www.centerspace.net/wp-content/uploads/2011/09/lr-150x150.png 150w, https://www.centerspace.net/wp-content/uploads/2011/09/lr-300x300.png 300w" sizes="(max-width: 492px) 100vw, 492px" /></a></pre>
<p><strong>More Information</strong></p>
<p>For more information, and many more examples, see:</p>
<ul>
<li>Whitepaper: <a href="https://www.centerspace.net/doc/NMath/whitepapers/NMath.ChartMicrosoft.pdf">NMath Visualization Using the Microsoft Chart Controls</a></li>
<li>Whitepaper: NMath Stats Visualization Using the Microsoft Chart Controls</li>
<li>the <a href="https://www.centerspace.net/doc/NMath/ref/">API docs</a> for the <code>CenterSpace.NMath.Charting.Microsoft </code>namespace</li>
</ul>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/math-charts">.NET Math with Microsoft Chart Controls, Revisited</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.centerspace.net/math-charts/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3538</post-id>	</item>
		<item>
		<title>Using NMath Charts with .NET 4.0</title>
		<link>https://www.centerspace.net/using-nmath-charts-with-net-4-0</link>
					<comments>https://www.centerspace.net/using-nmath-charts-with-net-4-0#respond</comments>
		
		<dc:creator><![CDATA[Ken Baldwin]]></dc:creator>
		<pubDate>Fri, 30 Sep 2011 23:10:47 +0000</pubDate>
				<category><![CDATA[NMath]]></category>
		<category><![CDATA[NMath Stats]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[.NET charting]]></category>
		<category><![CDATA[C# charts]]></category>
		<category><![CDATA[deploying .NET charts]]></category>
		<category><![CDATA[F# charts]]></category>
		<category><![CDATA[VB.NET charts]]></category>
		<guid isPermaLink="false">http://www.centerspace.net/blog/?p=3558</guid>

					<description><![CDATA[<p>The NMath Chart DLLs (NMathChartMicrosoft.dll and NMathStatsChartMicrosoft.dll) are built against the .NET 3.5 version of the Microsoft Chart Controls for .NET (System.Windows.Forms.DataVisualization). The .NET runtime will not automatically replace this reference with the version of the Microsoft Chart DLL built into the .NET 4.0 Framework, unless you explicitly tell it to do so by adding the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/using-nmath-charts-with-net-4-0">Using NMath Charts with .NET 4.0</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The NMath Chart DLLs (<strong>NMathChartMicrosoft.dll</strong> and <strong>NMathStatsChartMicrosoft.dll</strong>) are built against the .NET 3.5 version of the Microsoft Chart Controls for .NET (<strong>System.Windows.Forms.DataVisualization</strong>). The .NET runtime will not automatically replace this reference with the version of the Microsoft Chart DLL built into the .NET 4.0 Framework, unless you explicitly tell it to do so by adding the following lines to your <code>app.config</code>:</p>
<pre class="code">
<table><tbody>
<tr>
<td>
&lt;configuration&gt;
   ...
   &lt;runtime&gt;
      ...
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
         ...
         &lt;dependentAssembly&gt;
            &lt;assemblyIdentity name="System.Windows.Forms.DataVisualization"
              publicKeyToken="31bf3856ad364e35"/&gt;
            &lt;bindingRedirect oldVersion="3.5.0.0-3.5.0.0" newVersion="4.0.0.0"/&gt;
         &lt;/dependentAssembly&gt;
         ...
      &lt;/assemblyBinding&gt;
      ...
   &lt;/runtime&gt;
   ...
&lt;/configuration&gt;
</td>
</tr>
</tbody>
</table>
</pre>
<p>In this way, your application with charts can be <em>deployed to both .NET 3.5 and .NET 4.0.</em> Please note that all other NMath assemblies (with non-visual functionality) can be used in .NET 3.5 and .NET 4.0 without this step.</p>
<p>See <a href="https://msdn.microsoft.com/en-us/library/dd990785.aspx">this tutorial</a> for more information.</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/using-nmath-charts-with-net-4-0">Using NMath Charts with .NET 4.0</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.centerspace.net/using-nmath-charts-with-net-4-0/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3558</post-id>	</item>
		<item>
		<title>Using NMath with Microsoft Chart Controls for .NET</title>
		<link>https://www.centerspace.net/using-nmath-with-microsoft-chart-controls-for-net</link>
					<comments>https://www.centerspace.net/using-nmath-with-microsoft-chart-controls-for-net#respond</comments>
		
		<dc:creator><![CDATA[Ken Baldwin]]></dc:creator>
		<pubDate>Wed, 09 Mar 2011 11:04:53 +0000</pubDate>
				<category><![CDATA[NMath]]></category>
		<category><![CDATA[NMath Tutorial]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[.NET chart]]></category>
		<category><![CDATA[.NET plotting]]></category>
		<category><![CDATA[C# charts]]></category>
		<category><![CDATA[C# ploting]]></category>
		<category><![CDATA[Chart Controls for .NET]]></category>
		<category><![CDATA[VB.NET charts]]></category>
		<category><![CDATA[VB.NET plotting]]></category>
		<guid isPermaLink="false">http://www.centerspace.net/blog/?p=3262</guid>

					<description><![CDATA[<p><img class="excerpt" title="chart2" src="https://www.centerspace.net/blog/wp-content/uploads/2011/03/chart2.png"  /> The Microsoft Chart Controls for .NET provide an easy (and free) solution for visualizing NMath numerical types. The Chart controls are available as a separate download for .NET 3.5. Beginning in .NET 4.0, the Chart controls are part of the .NET Framework. </p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/using-nmath-with-microsoft-chart-controls-for-net">Using NMath with Microsoft Chart Controls for .NET</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In 2007, Microsoft acquired the Dundas chart components, in order to deliver data visualization directly within Microsoft products. In October 2008, they released the Microsoft Chart Controls for .NET, which includes the Dundas ASP.NET and Windows Forms Chart controls. The Chart controls are available as a <a href="https://www.microsoft.com/en-us/download/details.aspx?id=14422">separate download for .NET 3.5</a>. Beginning in .NET 4.0, the Chart controls are part of the .NET Framework. To use the Chart controls, add a reference to System.Windows.Forms.DataVisualization.</p>
<p>A <strong>Chart</strong> object contains one or more <strong>ChartArea</strong>s, each of which contain one or more data <strong>Series</strong>. Each <strong>Series</strong> has an associated chart type, and a <strong>DataPoint</strong> collection. <strong>DataPoint</strong>s can be manually appended or inserted into the collection, or added automatically when a series is bound to a datasource using either the <tt>DataBindY()</tt> or <tt>DataBindXY()</tt> method. Since any <strong>IEnumerable</strong> can act as a datasource, it&#8217;s easy to use an NMath vector or vector view (of a matrix row or column, for example) as a datasource.</p>
<p>For example, suppose we want to create a scatter plot of the first two columns of a 20 x 5 <strong>DoubleMatrix</strong> (that is, column 0 vs. column 1).</p>
<pre lang="csharp">DoubleMatrix data = new DoubleMatrix( 20, 5, new RandGenUniform() );
DoubleVector x = data.Col( 0 );
DoubleVector y = data.Col( 1 );</pre>
<p>Begin by creating a new <strong>Chart</strong> object, and optionally adding a <strong>Title</strong>.</p>
<pre lang="csharp">Chart chart = new Chart()
{
  Size = new Size( 500, 500 ),
};

Title title = new Title()
{
  Name = chart.Titles.NextUniqueName(),
  Text = "My Data",
  Font = new Font( "Trebuchet MS", 12F, FontStyle.Bold ),
};
chart.Titles.Add( title );</pre>
<p>Next, add a <strong>ChartArea</strong>.</p>
<pre lang="csharp">ChartArea area = new ChartArea()
{
  Name = chart.ChartAreas.NextUniqueName(),
};
area.AxisX.Title = "Col 0";
area.AxisX.TitleFont = new Font( "Trebuchet MS", 10F, FontStyle.Bold );
area.AxisX.MajorGrid.LineColor = Color.LightGray;
area.AxisX.RoundAxisValues();
area.AxisY.Title = "Col 1";
area.AxisY.TitleFont = new Font( "Trebuchet MS", 10F, FontStyle.Bold );
area.AxisY.MajorGrid.LineColor = Color.LightGray;
area.AxisY.RoundAxisValues();
chart.ChartAreas.Add( area );</pre>
<p>Finally, add a new data <strong>Series</strong>, and bind the datasource to the NMath x,y vectors.</p>
<pre lang="csharp">Series series = new Series()
{
  Name = "Points",
  ChartType = SeriesChartType.Point,
  MarkerStyle = MarkerStyle.Circle,
  MarkerSize = 8,
};
series.Points.DataBindXY( x, y );
chart.Series.Add( series );</pre>
<p>To display the chart, we can use a utility function like this, which shows the given chart in a default form running in a new thread.</p>
<pre lang="csharp">public static void Show( Chart chart )
{
  Form form = new Form();
  form.Size = new Size( chart.Size.Width + 20, chart.Size.Height + 40 );
  form.Controls.Add( chart );
  Thread t = new Thread( () =&gt; Application.Run( form ) );
   t.Start();
}</pre>
<p>After calling</p>
<pre lang="csharp">Show( chart );</pre>
<p>the result looks like this:</p>
<p style="text-align: center;"><a href="https://www.centerspace.net/blog/wp-content/uploads/2011/03/chart11.png"><img decoding="async" loading="lazy" class="size-full wp-image-3267 aligncenter" title="chart1" src="https://www.centerspace.net/blog/wp-content/uploads/2011/03/chart11.png" alt="Microsoft Chart Controls for .NET" width="491" height="486" srcset="https://www.centerspace.net/wp-content/uploads/2011/03/chart11.png 491w, https://www.centerspace.net/wp-content/uploads/2011/03/chart11-300x296.png 300w" sizes="(max-width: 491px) 100vw, 491px" /></a></p>
<p>Of course, you can easily plot more complicated data as well. For instance, suppose we fit a 4th degree polynomial to this (random) data:</p>
<pre lang="csharp">int degree = 4;
PolynomialLeastSquares pls = new PolynomialLeastSquares( degree, x, y );</pre>
<p>To add the fitted polynomial to the cart, just add a new data <strong>Series</strong> interpolating over the range of x values.</p>
<pre lang="csharp">Series series2 = new Series()
{
  Name = "Polynomial",
  ChartType = SeriesChartType.Line,
  MarkerStyle = MarkerStyle.None,
};
int numInterpolatedValues = 100;
double xmin = NMathFunctions.MinValue( x );
double xmax = NMathFunctions.MaxValue( x );
double step = ( xmax - xmin ) / ( numInterpolatedValues - 1 );
DoubleVector xi = new DoubleVector( numInterpolatedValues, xmin, step );
series2.Points.DataBindXY( xi, pls.FittedPolynomial.Evaluate( xi ) );
chart.Series.Add( series2 );</pre>
<p>Let&#8217;s also add a subtitle with the fitted function, and a <strong>Legend</strong>.</p>
<pre lang="csharp">Title subtitle = new Title()
{
  Name = chart.Titles.NextUniqueName(),
  Text = "f(x) = " + pls.FittedPolynomial.ToString( "N2" ),
};
chart.Titles.Add( subtitle );

Legend legend = new Legend()
{
  Name = chart.Legends.NextUniqueName(),
  DockedToChartArea = chart.ChartAreas[0].Name,
};
chart.Legends.Add( legend );</pre>
<p>Now the chart looks like this:<br />
<a href="https://www.centerspace.net/blog/wp-content/uploads/2011/03/chart2.png"><img decoding="async" loading="lazy" class="aligncenter size-full wp-image-3268" title="chart2" src="https://www.centerspace.net/blog/wp-content/uploads/2011/03/chart2.png" alt="" width="491" height="494" srcset="https://www.centerspace.net/wp-content/uploads/2011/03/chart2.png 491w, https://www.centerspace.net/wp-content/uploads/2011/03/chart2-150x150.png 150w, https://www.centerspace.net/wp-content/uploads/2011/03/chart2-298x300.png 298w" sizes="(max-width: 491px) 100vw, 491px" /></a></p>
<p>If you add a <strong>Chart</strong> control to your application using the visual designer (by dragging a <strong>Chart</strong> control from the Data category in the Toolbox), this generates code to create a default <strong>Chart</strong>, with a single <strong>ChartArea</strong>, <strong>Series</strong>, and <strong>Legend</strong>. You can then edit the properties in the Properties tab, and bind the generated <strong>Series</strong> to an NMath datasource. For example:</p>
<pre lang="csharp">public Form1()
{
  InitializeComponent();

  DoubleMatrix data = new DoubleMatrix( 20, 5, new RandGenUniform() );
  this.chart1.Series[0].Points.DataBindXY( data.Col(0), data.Col(1) );
}</pre>
<p>The Microsoft Chart Controls for .NET provide an easy (and free) solution for visualizing NMath numerical types.</p>
<p>Ken</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/using-nmath-with-microsoft-chart-controls-for-net">Using NMath with Microsoft Chart Controls for .NET</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.centerspace.net/using-nmath-with-microsoft-chart-controls-for-net/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3262</post-id>	</item>
	</channel>
</rss>
