c#实现matlab的数组plot功能

新建一个Form1,写入下面代码,并在Form1添加一个print事件,Form1_Paint。Form1_Paint中有一个随机数二维数组 twoDim,把他改成你想要输出的数组。即可在Form1像matlab plot一样画出二维数组。
原理:
通过调用
e.Graphics.DrawLine作图
并通过Color MapRainbowColor方法定义不同数值对应的颜色
对数组遍历后画出数组的彩色图

但是注意,在c#中这样做需要执行遍历语句多次,作图的效率很低!!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace COLORMAP
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        // Draw rainbow colors on the form.
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Random r = new Random();
            float[,] twoDim = new float[100, 100];
            for (int i = twoDim.GetLowerBound(0); i <= 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值