Add second y-axis to excel plot
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Julian Hapke
il 23 Giu 2014
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 Commenti
Vedere anche
Categorie
Scopri di più su Bar Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!