■ VectorField 클래스의 ScaledArrowheads/AnchorMarkerSize 속성을 사용해 스케일 화살촉을 적용하는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55 56 57 58 59 60
|
using System; using System.Windows.Forms; using ScottPlot; using ScottPlot.Plottable; using ScottPlot.Statistics; 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[] xPositionArray = DataGen.Range(0, 10); double[] yPositionArray = DataGen.Range(0, 10); Vector2[,] vectorArray = new Vector2[xPositionArray.Length, yPositionArray.Length]; for(int x = 0; x < xPositionArray.Length; x++) { for(int y = 0; y < yPositionArray.Length; y++) { vectorArray[x, y] = new Vector2 ( x : Math.Sin(xPositionArray[x]), y : Math.Sin(yPositionArray[y]) ); } } VectorField vectorField = plot.AddVectorField(vectorArray, xPositionArray, yPositionArray); vectorField.ScaledArrowheads = true; vectorField.Anchor = ArrowAnchor.Base; vectorField.MarkerSize = 3; this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddVectorField 메소드를 사용해 커스텀 스케일 팩터를 적용하는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55 56 57
|
using System; using System.Windows.Forms; using ScottPlot; using ScottPlot.Statistics; 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.Range(-1.5, 1.5, 0.25); double[] yValueArray = DataGen.Range(-1.5, 1.5, 0.25); Vector2[,] vectorArray = new Vector2[xValueArray.Length, yValueArray.Length]; for(int i = 0; i < xValueArray.Length; i++) { for(int j = 0; j < yValueArray.Length; j++) { double x = xValueArray[i]; double y = yValueArray[j]; double e = Math.Exp(-x * x - y * y); double deltaX = (1 - 2 * x * x) * e; double deltaY = -2 * x * y * e; vectorArray[i, j] = new Vector2(deltaX, deltaY); } } plot.AddVectorField(vectorArray, xValueArray, yValueArray, scaleFactor : 0.3); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddVectorField 메소드를 사용해 커스텀 색상맵을 적용하는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55 56 57 58 59 60
|
using System; using System.Windows.Forms; using ScottPlot; using ScottPlot.Drawing; using ScottPlot.Statistics; 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.Range(-5, 5, 0.5); double[] yValueArray = DataGen.Range(-5, 5, 0.5); Vector2[,] vectorArray = new Vector2[xValueArray.Length, yValueArray.Length]; double r = 0.5; for(int i = 0; i < xValueArray.Length; i++) { for(int j = 0; j < yValueArray.Length; j++) { double x = yValueArray[j]; double y = -9.81 / r * Math.Sin(xValueArray[i]); vectorArray[i, j] = new Vector2(x, y); } } plot.AddVectorField(vectorArray, xValueArray, yValueArray, colormap : Colormap.Turbo); plot.XLabel("θ"); plot.YLabel("dθ/dt"); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddVectorField 메소드를 사용해 주어진 각도와 크기에 따라 벡터를 설정하는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55
|
using System; using System.Windows.Forms; using ScottPlot; using ScottPlot.Statistics; 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.Range(-5, 6); double[] yValueArray = DataGen.Range(-5, 6); Vector2[,] vectorArray = new Vector2[xValueArray.Length, yValueArray.Length]; for(int i = 0; i < xValueArray.Length; i++) { for(int j = 0; j < yValueArray.Length; j++) { double slope = -xValueArray[i]; double magnitude = Math.Abs(xValueArray[i]); double angle = Math.Atan(slope); vectorArray[i, j] = new Vector2(Math.Cos(angle) * magnitude, Math.Sin(angle) * magnitude); } } plot.AddVectorField(vectorArray, xValueArray, yValueArray); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddVectorField 메소드를 사용해 벡터 필드를 그리는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55
|
using System; using System.Windows.Forms; using ScottPlot; using ScottPlot.Statistics; 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[] xPositionArray = DataGen.Range(0, 10); double[] yPositionArray = DataGen.Range(0, 10); Vector2[,] vectorArray = new Vector2[xPositionArray.Length, yPositionArray.Length]; for(int x = 0; x < xPositionArray.Length; x++) { for(int y = 0; y < yPositionArray.Length; y++) { vectorArray[x, y] = new Vector2 ( x : Math.Sin(xPositionArray[x]), y : Math.Sin(yPositionArray[y]) ); } } plot.AddVectorField(vectorArray, xPositionArray, yPositionArray); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Tooltip 클래스에서 툴팁 색상을 설정하는 방법을 보여준다. ▶ 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 49 50
|
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[] yValueArray = DataGen.Sin(50); plot.AddSignal(yValueArray); Tooltip tooltip = plot.AddTooltip("This point has\na negative slope", 25, yValueArray[25]); tooltip.BorderWidth = 5; tooltip.BorderColor = Color.Navy; tooltip.FillColor = Color.Blue; tooltip.Font.Size = 24; tooltip.Font.Color = Color.White; tooltip.ArrowSize = 15; this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Tooltip 클래스의 Font 속성을 사용해 툴팁 폰트를 설정하는 방법을 보여준다. ▶ 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 49 50 51
|
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[] yValueArray = DataGen.Sin(50); plot.AddSignal(yValueArray); Tooltip tooltip1 = plot.AddTooltip("Top", 12, yValueArray[12]); tooltip1.Font.Size = 24; tooltip1.Font.Color = Color.Magenta; Tooltip tooltip2 = plot.AddTooltip("Negative Slope", 25, yValueArray[25]); tooltip2.Font.Name = "Comic Sans MS"; tooltip2.Font.Bold = true; this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddTooltip 메소드를 사용해 툴팁을 추가하는 방법을 보여준다. ▶ 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[] yValueArray = DataGen.Sin(50); plot.AddSignal(yValueArray); plot.AddTooltip(label : "Special Point", x : 17, y : yValueArray[17]); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddText 메소드를 사용해 커스텀 폰트를 적용하는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
using System.Drawing; using System.Windows.Forms; using ScottPlot; using ScottPlot.Renderable; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Plot plot = new Plot(800, 600); plot.AddSignal(DataGen.Sin(51), label : "sin"); plot.AddSignal(DataGen.Cos(51), label : "cos"); plot.AddText ( "very graph", 25, 0.8, new ScottPlot.Drawing.Font() { Name = "comic sans ms", Size = 24, Color = Color.Blue, Bold = true } ); plot.AddText ( "so data", 0, 0, new ScottPlot.Drawing.Font() { Name = "comic sans ms", Size = 42, Color = Color.Magenta, Bold = true } ); plot.AddText ( "many documentation", 3, -0.6, new ScottPlot.Drawing.Font() { Name = "comic sans ms", Size = 18, Color = Color.DarkBlue, Bold = true } ); plot.AddText ( "wow.", 10, 0.6, new ScottPlot.Drawing.Font() { Name = "comic sans ms", Size = 36, Color = Color.Green, Bold = true } ); plot.AddText ( "NuGet", 32, 0, new ScottPlot.Drawing.Font() { Name = "comic sans ms", Size = 24, Color = Color.Gold, Bold = true } ); plot.YAxis.Label ( label : "vertical units", fontName : "impact", size : 24, color : Color.Red, bold : true ); plot.XAxis.Label ( label : "horizontal units", fontName : "georgia", size : 24, color : Color.Blue, bold : true ); plot.XAxis2.Label ( label : "Impressive Graph", size : 24, color : Color.Purple, bold : true ); plot.XAxis.TickLabelStyle(color : Color.DarkBlue , fontName : "comic sans ms", fontSize : 16); plot.YAxis.TickLabelStyle(color : Color.DarkGreen, fontName : "comic sans ms", fontSize : 16); Legend legend = plot.Legend(); legend.FontName = "comic sans ms"; legend.FontSize = 18; legend.FontColor = Color.DarkBlue; legend.FontBold = true; this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Text 클래스의 Alignment/Rotation 속성을 사용해 텍스트를 정렬/회전하는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55 56 57 58 59 60 61
|
using System; 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); Alignment[] alignmentArray = (Alignment[])Enum.GetValues(typeof(Alignment)); for(int i = 0; i < alignmentArray.Length; i++) { double fraction = (double)i / alignmentArray.Length; double x = Math.Sin(fraction * Math.PI * 2); double y = Math.Cos(fraction * Math.PI * 2); Text text = plot.AddText(alignmentArray[i].ToString(), x, y); text.Alignment = alignmentArray[i]; text.Rotation = 5; text.BorderSize = 2; text.BorderColor = Color.Navy; text.BackgroundFill = true; text.BackgroundColor = Color.LightSteelBlue; text.Font.Color = Color.Black; plot.AddPoint(x, y, Color.Red, 10); } plot.Margins(0.5, 0.2); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddText 메소드를 사용해 텍스트를 추가하는 방법을 보여준다. ▶ 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
|
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); int pointCount = 51; double[] xValueArray = DataGen.Consecutive(pointCount); double[] yValueArray1 = DataGen.Sin(pointCount); double[] yValueArray2 = DataGen.Cos(pointCount); plot.AddScatter(xValueArray, yValueArray1); plot.AddScatter(xValueArray, yValueArray2); plot.AddText("샘플 텍스트", 10, 0.5, size : 16, color : Color.Blue); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ SignalPlotXYConst<TX,TY> 클래스의 StepDisplay 속성을 사용해 단계형 시그널 XY 차트를 그리는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55 56
|
using System; 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); Random random = new Random(0); int pointCount = 100000; double[] yValueArray = new double[pointCount]; double[] xValueArray = new double[pointCount]; for(int i = 1; i < yValueArray.Length; i++) { yValueArray[i] = yValueArray[i - 1] + random.NextDouble() - 0.5; xValueArray[i] = xValueArray[i - 1] + random.NextDouble(); } SignalPlotXYConst<double, double> signalPlotXYConst = plot.AddSignalXYConst(xValueArray, yValueArray); signalPlotXYConst.StepDisplay = true; plot.SetAxisLimits(18700, 18730, -49.25, -46.75); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddSignalXYConst 메소드에서 데이터 타입이 다른 X/Y 데이터를 사용하는 방법을 보여준다. ▶ 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 49 50 51 52
|
using System; using System.Linq; 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); Random random = new Random(0); int pointCount = 1000000; double[] sineValueArray = DataGen.Sin(pointCount, 3); double[] noiseValueArray = DataGen.RandomNormal(random, pointCount, 0, 0.5); float[] yValueArray = sineValueArray.Zip(noiseValueArray, (s, n) => s + n).Select(x => (float)x).ToArray(); int[] xValueArray = Enumerable.Range(0, pointCount) .Select(x => (int)x) .Select(x => x > 500000 ? x + 1_000000 : x) .Select(x => x > 200000 ? x + 100000 : x) .ToArray(); plot.AddSignalXYConst(xValueArray, yValueArray); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddSignalXYConst 메소드를 사용해 시그널 XY 차트를 그리는 방법을 보여준다. ▶ 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 49 50 51
|
using System; 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); Random random = new Random(0); int pointCount = 100_000; double[] yValueArray = new double[pointCount]; double[] xValueArray = new double[pointCount]; for(int i = 1; i < yValueArray.Length; i++) { yValueArray[i] = yValueArray[i - 1] + random.NextDouble() - 0.5; xValueArray[i] = xValueArray[i - 1] + random.NextDouble(); } plot.AddSignalXYConst(xValueArray, yValueArray); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ SignalPlotXY 클래스의 FillBelow 메소드를 사용해 시그널 XY 차트 아래 채우는 방법을 보여준다. ▶ 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
|
using System; 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, double[] yValueArray) = DataGen.RandomWalk2D(new Random(0), 5000); SignalPlotXY signalPlotXY = plot.AddSignalXY(xValueArray, yValueArray); signalPlotXY.FillBelow(); plot.Margins(x : 0); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ SignalPlotXY 클래스의 StepDisplay/MarkerSize 속성을 사용해 단계형 시그널 XY 차트를 그리는 방법을 보여준다. ▶ 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; 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[] xs, double[] ys) = DataGen.RandomWalk2D(new Random(0), 5000); SignalPlotXY signalPlotXY = plot.AddSignalXY(xs, ys); signalPlotXY.StepDisplay = true; signalPlotXY.MarkerSize = 0; plot.SetAxisLimits(110, 140, 17.5, 27.5); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddSignalXY 메소드를 사용해 상이한 밀도를 갖는 시그널 XY 차트를 그리는 방법을 보여준다. ▶ 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 49 50 51 52 53 54 55 56 57 58 59
|
using System; using System.Linq; 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); Random rand = new Random(0); int pointCount = 5_000; double[] sineValueArray = DataGen.Sin(pointCount, 3); double[] noiseValueArray = DataGen.RandomNormal(rand, pointCount, 0, 0.5); double[] yValueArray = sineValueArray.Zip(noiseValueArray, (s, n) => s + n).ToArray(); double[] xValueArray = new double[pointCount]; double x = 0; for(int i = 0; i < pointCount; i++) { bool lowDensityPoint = (i % 1_000) < 10; x += lowDensityPoint ? 10 : 0.05; xValueArray[i] = x; } plot.AddSignalXY(xValueArray, yValueArray); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddSignalXY 메소드를 사용해 간격이 있는 시그널 XY 차트를 그리는 방법을 보여준다. ▶ 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 49 50 51 52 53
|
using System; using System.Linq; 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); Random randOm = new Random(0); int pointCount = 10000; double[] xValueArray = Enumerable.Range(0, pointCount) .Select(x => (double)x) .Select(x => x > 3000 ? x + 10000 : x) .Select(x => x > 7000 ? x + 20000 : x) .ToArray(); double[] sineValueArray = DataGen.Sin(pointCount, 3); double[] noiseValueArray = DataGen.RandomNormal(randOm, pointCount, 0, 0.5); double[] yValueArray = sineValueArray.Zip(noiseValueArray, (s, n) => s + n).ToArray(); plot.AddSignalXY(xValueArray, yValueArray); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ SignalPlotXY 클래스의 OffsetX/OffsetY 속성을 사용해 데이터를 이동시키는 방법을 보여준다. ▶ 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
|
using System; 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[] xs, double[] ys) = DataGen.RandomWalk2D(new Random(0), 5_000); SignalPlotXY signalPlotXY = plot.AddSignalXY(xs, ys); signalPlotXY.OffsetX = 10000; signalPlotXY.OffsetY = 100; this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddSignalXY 메소드를 사용해 시그널 XY 차트를 그리는 방법을 보여준다. ▶ 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
|
using System; 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, double[] yValueArray) = DataGen.RandomWalk2D(new Random(0), 5000); plot.AddSignalXY(xValueArray, yValueArray); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ DataGen 클래스의 RandomWalk2D 정적 메소드를 사용해 임의 X/Y 배열을 구하는 방법을 보여준다. ▶ 예제 코드 (C#)
|
using System; using ScottPlot; (double[] xValueArray, double[] yValueArray) = DataGen.RandomWalk2D(new Random(0), 5000); |
■ Plot 클래스의 AddSignalConst 메소드를 사용해 제너릭 타입 데이터를 갖고 시그널 차트를 그리는 방법을 보여준다. ▶ 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); int[] yValueArray = { 2, 6, 3, 8, 5, 6, 1, 9, 7 }; plot.AddSignalConst(yValueArray); plot.Title("시그널 차트 : 정수 배열 데이터 표시"); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ Plot 클래스의 AddSignalConst 메소드를 사용해 시그널 차트를 그리는 방법을 보여준다. ▶ 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
|
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.AddSignalConst(valueArray); plot.Title("백만 포인트"); plot.Benchmark(); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ SignalPlot 클래스의 FillAboveAndBelow 메소드를 사용해 시그널 차트 위/아래를 채우는 방법을 보여준다. ▶ 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 49 50 51
|
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[] data = DataGen.RandomWalk(1000); plot.Style(Style.Gray1); SignalPlot signalPlot = plot.AddSignal(data); signalPlot.FillAboveAndBelow(Color.Green, Color.Transparent, Color.Transparent, Color.Red, 1); signalPlot.MarkerSize = 0; signalPlot.BaselineY = 5; signalPlot.Color = Color.Black; plot.Margins(x : 0); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip
■ SignalPlot 클래스의 FillAboveAndBelow 메소드를 사용해 시그널 차트 위/아래를 채우는 방법을 보여준다. ▶ 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[] yValueArray = DataGen.RandomWalk(1000); SignalPlot signalPlot = plot.AddSignal(yValueArray); signalPlot.FillAboveAndBelow(Color.Green, Color.Red); signalPlot.BaselineY = 7; signalPlot.Color = Color.Black; plot.Margins(x: 0); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |
TestProject.zip