Add second y-axis to excel plot
1 回表示 (過去 30 日間)
古いコメントを表示
Chart = invoke(Workbook.Charts,'Add');
Chart.ChartType = 'xlXYScatterSmooth';
Chart.Axes(1).HasTitle = true;
Chart.Axes(1).AxisTitle.Text = 'Time (sec)';
Chart.Axes(2).HasTitle = true;
Chart.Axes(2).AxisTitle.Text = 'Pressure (psig/psid)';
Chart.Axes(2,2).HasTitle = true;
Chart.Axes(2,2).AxisTitle.Text = 'RPM and Flows (pph)';
invoke(Chart, 'SetSourceData', Excel.Range('Sheet1!A3:D6'));
If I use:
Chart.Axes(2,2).HasTitle = true;
Chart.Axes(2,2).AxisTitle.Text = 'RPM and Flows (pph)';
to obtain the second y axis, I get the following message:
Error using Interface.000208D6_0000_0000_C000_000000000046/Axes
Invoke Error, Dispatch Exception: Unspecified error
Error in Trial (line 14)
Chart.Axes(2,2).HasTitle = true;
How can a second y-axis be added to the right of the chart?
0 件のコメント
回答 (1 件)
Julian Hapke
2014 年 6 月 23 日
hi anda,
if you have data in your chart, that's supposed to be scaled to the secondary y-axis, just move the plot there, here's an example:
xls = actxserver('Excel.Application');
xls.Visible=true;
a=num2cell([(1:10)' (1:10)' (10.^(1:10))']);
wb=xls.Workbooks.Add;
set(wb.ActiveSheet.Range('$A$1:$C$10'),'Value',a);
crt=wb.ActiveSheet.Shapes.AddChart(75);
getscale(crt)
s2=crt.Chart.SeriesCollection(2);
set(s2,'AxisGroup','xlSecondary');
if you just want the other axis with only one plot, you need some dummy data.
regards
julian
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Bar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!