How to set programmatically set ScaleType to Logarithmic in Excel Plot
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have code that successfully opens an Excel workbook in office 365 and plots data in an XYScatter plot. However, I wish for both the X and Y axes to have logarithmic scales but unfortunatley I cannot find the correct enumeration with what I believe is the correct axes property "ScaleType". I have tried two alternative enumerations:
- ScaleType = 'xlLogarithmic' For this I get the error "There is no enumerated value named 'xlLogarithmic'."
- ScaleType = 'xlScaleLogarithmic'; For this I get the error "Invoke Error, Dispatch Exception: Unspecified error
Here is my code
excelApp = actxserver('Excel.Application');
myWorkBook = excelApp.workbooks.Add;
workSheets = myWorkBook.Sheets;
myWorkSheet = excelApp.Activesheet ;
line{1} = myPlots.SeriesCollection.NewSeries;
myPlots.SeriesCollection(1).XValue = myWorkSheet.Range('A2:A24');
myPlots.SeriesCollection(1).Values = myWorkSheet.Range('B2:B24');
line{1}.ChartType = 'xlXYScatterLinesNoMarkers';
%Below is where i get the error for either approach
myPlots.Axes(1).ScaleType = 'xlLogarithmic';
myPlots.Axes(1).ScaleType = 'xlScaleLogarithmic';
Any suggestions?
Thanks
0 Commenti
Risposte (1)
Rohit Kulkarni
il 31 Ago 2023
Hi Scott,
I understand that you are facing the error in using the ScaleType property. According to the Excel Documentation there are two xlScaleType enumerations, xlScaleLinear and xlScaleLogarithmic.
xlScaleLogarithmic is used to set the scale to logarithmic.
Use xlScaleLogarithmic in the following way:
myPlots("myPlot1").Axes(xlValue).ScaleType =xlScaleLogarithmic
This will set the value axis in myPlot1 to use a logarithmic scale.
Refer the documentation link for details:
Hope it helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Discrete Data 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!