Stackedplot with x-axis vector
Afficher commentaires plus anciens
Hello,
I am very new and am struggling to get stackedplot to work at all.
I would like to use stackedplot to create some stacked line curves with a common x-axis. The x-axis should be wavelength values that I have as a column in my spreadsheet ('Channels'). The two line graphs should be intensity values of 'illite' and 'kaolinite', also listed in columns.
This is the code I have (with spreadsheet specifications removed):
close all
figure
tbl = readtable('___','Sheet','___');
head(tbl,2);
stackedplot({'Channel'},{'illite','kaolinite'});
I get the error:
Error using stackedplot (line 76)
Expected x to be one of these types:
datetime, duration, double, single, uint8, uint16,
uint32, uint64, int8, int16, int32, int64, logical
Error in stackedplottest (line 14)
stackedplot({'Channel'},{'illite','kaolinite'});
Please help :(
Réponses (1)
Steven Lord
le 24 Fév 2020
Where is the data from which you want to create the stackedplot stored?
stackedplot({'Channel'},{'illite','kaolinite'});
I think you want to create the stackedplot from the variable Channel in the table array tbl. But where have you told stackedplot to use the data from the variable tbl?
4 commentaires
Erin Gibbons
le 24 Fév 2020
Steven Lord
le 24 Fév 2020
The first input to the stackedplot function is supposed to be the table that contains the data you want to use to create the stacked plot. You accidentally omitted that input. Pass tbl as the first input, {'Channel'} as the second, etc.
Erin Gibbons
le 24 Fév 2020
Steven Lord
le 24 Fév 2020
Okay. I didn't read the documentation quite as thoroughly as I should have. Using one of the sample table arrays from the stackedplot documentation:
tbl = readtable('outages.csv');
I want to plot two of the variables, Loss and Customers, and I want to use the OutageTime as the X axis.
stackedplot(tbl, {'Loss', 'Customers'}, 'XVariable', 'OutageTime')
So I believe what you want is:
stackedplot(tbl, {'illite', 'kaolinite'}, 'XVariable', 'Channel')
Catégories
En savoir plus sur Entering Commands dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!