nplot用法(线、柱、标签、移动窗体)

                myPlot.Clear();

                //加入网格
                Grid mygrid = new Grid();
                myPlot.Add(mygrid);
                myPlot.Title = "测试";


                LinePlot lp = new LinePlot();
                double[] a = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
                string[] b = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", };
                double[] ab = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                ArrayList dates = new ArrayList();
                dates.Add(Convert.ToDateTime("2007-01-01"));
                dates.Add(Convert.ToDateTime("2008-01-02 "));
                dates.Add(Convert.ToDateTime("2008-01-03 "));
                dates.Add(Convert.ToDateTime("2008-01-04 "));
                dates.Add(Convert.ToDateTime("2008-01-05 "));
                dates.Add(Convert.ToDateTime("2008-01-06 "));
                dates.Add(Convert.ToDateTime("2008-01-07 "));
                dates.Add(Convert.ToDateTime("2008-01-08 "));
                dates.Add(Convert.ToDateTime("2008-01-09 "));
                dates.Add(Convert.ToDateTime("2008-01-10 "));
                dates.Add(Convert.ToDateTime("2008-01-11 "));
                dates.Add(Convert.ToDateTime("2008-02-12 "));
                lp.AbscissaData = dates;

                //柱状
                BarPlot storeGrowth = new BarPlot();
                storeGrowth.AbscissaData = dates;
                storeGrowth.OrdinateDataTop = a;
                storeGrowth.OrdinateDataBottom = ab;
                storeGrowth.FillBrush = NPlot.RectangleBrushes.Solid.Red;
                //storeGrowth.BorderPen = new Pen( Color.Black, 2.0f );
                myPlot.Add(storeGrowth);

                //标签
                LabelPointPlot tp1 = new LabelPointPlot();
                tp1.AbscissaData = dates;
                tp1.OrdinateData  = a;
                tp1.TextData = b;
                tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
                tp1.Marker = new Marker(Marker.MarkerType.None, 10);
                myPlot.Add(tp1);


                //lp.
                lp.DataSource = a;
                lp.Pen = new Pen(Color.Blue, 3.0f);
                lp.Label = "Gaussian Function";
                myPlot.Add(lp);
                myPlot.XAxis1.Label = "时间";
                myPlot.YAxis1.Label = "次数";
                //myPlot.XAxis1.WorldLength = 60 * 60 * 24;
                //设置网格距离
                //myPlot.XAxis1.WorldMin += myPlot.XAxis1.WorldLength/ 12;//WorldLength=n*24*60*60;
                //myPlot.XAxis1.WorldMax -= myPlot.XAxis1.WorldLength / 2;
                //myPlot.XAxis1.
                //myPlot.XAxis1.WorldLength = 10;
                //myPlot.
                //让日期斜45度。
                myPlot.XAxis1.TicksLabelAngle = 45;

                //下面代码可让窗体移动begin;
                myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
                //myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
                myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(true));

                myPlot.Refresh();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值