■ Plot 클래스의 AddFill 메소드를 사용해 해시를 채우는 방법을 보여준다.
▶ 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 |
using System.Drawing; using System.Linq; using System.Windows.Forms; using ScottPlot; using ScottPlot.Drawing; 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 supplyFunction(double q) => 5 * q + 1; double demandFunction(double q) => -3 * q + 17; const double priceFloor = 12.5; double[] xValueArray = DataGen.Consecutive(5); double[] supplyArray = xValueArray.Select(supplyFunction).ToArray(); double[] demandArray = xValueArray.Select(demandFunction).ToArray(); plot.AddScatter(xValueArray, supplyArray, markerShape : MarkerShape.none, label : "공급"); plot.AddScatter(xValueArray, demandArray, markerShape : MarkerShape.none, label : "수요"); plot.AddHorizontalLine(priceFloor, label : "가격 하한선"); double[] boundArray1 = new double[] { 0, 1.5 }; Polygon polygon1 = plot.AddFill ( boundArray1, boundArray1.Select(supplyFunction).ToArray(), boundArray1, Enumerable.Repeat(priceFloor, 2).ToArray() ); polygon1.LineWidth = 0; polygon1.FillColor = Color.LawnGreen; polygon1.HatchColor = Color.Transparent; polygon1.HatchStyle = HatchStyle.StripedWideDownwardDiagonal; polygon1.Label = "가능한 최대 생산자 잉여"; double[] boundArray2 = new double[] { 1.2, 2.3 }; Polygon polygon2 = plot.AddFill ( boundArray2, boundArray2.Select(supplyFunction).ToArray(), boundArray2, Enumerable.Repeat(priceFloor, 2).ToArray() ); polygon2.LineWidth = 0; polygon2.FillColor = Color.Transparent; polygon2.HatchColor = Color.Red; polygon2.HatchStyle = HatchStyle.StripedWideDownwardDiagonal; polygon2.Label = "가능한 최소 생산자 잉여"; plot.Legend(); this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |