Stackedplot with x-axis vector
显示 更早的评论
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 :(
回答(1 个)
Steven Lord
2020-2-24
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 个评论
Erin Gibbons
2020-2-24
Steven Lord
2020-2-24
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
2020-2-24
Steven Lord
2020-2-24
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')
类别
在 帮助中心 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!