1

如何从 Matlab 绘制 excel 条形图?

我能够绘制折线图。

e = actxserver('excel.application');
eWs = e.Workbooks;
eW = eWs.Add;
eS = eW.ActiveSheet;
e.Visible = 1;

x=(0:2:100)';y=sin(x);
eS.Range('A1:B50').Value = [x y];

eCO = eS.ChartObjects.Add(100, 30, 400, 250);
eC = eCO.Chart;
eC.SeriesCollection.NewSeries;

eC.SeriesCollection(1).Value = eS.Range('B1:B50');
eC.SeriesCollection(1).XValue = eS.Range('A1:A50');
eCO.Chart.ChartType = 1;
eCO.Chart.ChartType = 65;

eCO.Chart.HasTitle = true;
eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again

eW.Close;e.Quit;delete(e);
4

1 回答 1

0

好的,我刚发帖就知道了。
我们可以通过改变

eCO.Chart.ChartType = 65;eCO.Chart.ChartType = 57;

e = actxserver('excel.application');
eWs = e.Workbooks;
eW = eWs.Add;
eS = eW.ActiveSheet;
e.Visible = 1;

x=(0:2:100)';y=sin(x);
eS.Range('A1:B50').Value = [x y];

eCO = eS.ChartObjects.Add(100, 30, 400, 250);
eC = eCO.Chart;
eC.SeriesCollection.NewSeries;

eC.SeriesCollection(1).Value = eS.Range('B1:B50');
eC.SeriesCollection(1).XValue = eS.Range('A1:A50');
eCO.Chart.ChartType = 1;
eCO.Chart.ChartType = 57;

eCO.Chart.HasTitle = true;
eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again

eW.Close;e.Quit;delete(e);

如需进一步参考其他图表,请查看此http://it.toolbox.com/wiki/index.php/EXCEL_Chart_Type_Enumeration

于 2013-08-10T19:36:29.143 回答