■ Plot 클래스의 Clear 메소드를 사용해 시리즈를 모두 제거하는 방법을 보여준다. ▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
using System.Drawing; using System.Windows.Forms; using ScottPlot; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Plot plot = new Plot(800, 600); double[] xValueArray = DataGen.Consecutive(51); double[] sineValueArray = DataGen.Sin(51); double[] cosineValueArray = DataGen.Sin(51); plot.AddScatter(xValueArray, sineValueArray, color : Color.Red); plot.Clear(); plot.AddScatter(xValueArray, cosineValueArray, color : Color.Blue); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 Remove 메소드를 사용해 시리즈를 제거하는 방법을 보여준다. ▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
using System.Drawing; using System.Windows.Forms; using ScottPlot; using ScottPlot.Plottable; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Plot plot = new Plot(800, 600); double[] xValueArray = DataGen.Consecutive(51); double[] sineValueArray = DataGen.Sin(51); double[] cosineValueArray = DataGen.Sin(51); ScatterPlot sineScatterPlot = plot.AddScatter(xValueArray, sineValueArray , color : Color.Red ); ScatterPlot cosineScatterPlot = plot.AddScatter(xValueArray, cosineValueArray, color : Color.Blue); plot.Remove(sineScatterPlot); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ ScatterPlot 클래스의 MarkerShape/MarkerSize 속성을 사용해 마커 모양을 설정하는 방법을 보여준다. ▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
using System.Drawing; using System.Windows.Forms; using ScottPlot; using ScottPlot.Plottable; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Plot plot = new Plot(800, 600); double[] xValueArray = DataGen.Consecutive(51); double[] sineValueArray = DataGen.Sin(51); ScatterPlot scatterPlot = new ScatterPlot(xValueArray, sineValueArray); scatterPlot.MarkerShape = MarkerShape.filledDiamond; scatterPlot.MarkerSize = 10; scatterPlot.Color = Color.Navy; plot.Add(scatterPlot); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 SetAxisLimits 메소드를 사용해 축 레이블과 제한을 설정하는 방법을 보여준다. ▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
using System.Windows.Forms; using ScottPlot; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Plot plot = new Plot(800, 600); double[] timeArray = DataGen.Consecutive(51); double[] voltageArray = DataGen.Sin(51); plot.AddScatter(timeArray, voltageArray); plot.XAxis.Label("시간(밀리초)"); plot.YAxis.Label("전압(mV)"); plot.XAxis2.Label("실험"); plot.SetAxisLimits(-20, 80, -2, 2); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddSignal 메소드를 사용해 시그널 차트를 그리는 방법을 보여준다. ▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
using System.Windows.Forms; using ScottPlot; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Plot plot = new Plot(800, 600); double[] valueArray = DataGen.RandomWalk(1000000); plot.AddSignal(valueArray, sampleRate : 48000); plot.Title("백만 포인트"); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ ScottPlot.WinForms 누겟을 설치하는 방법을 보여준다. 1. Visual Studio를 실행한다. 2. [도구] / [NuGet 패키지 관리자] / [패키지 관리자 콘솔] 메뉴를 실행한다.
더 읽기