Importing table and making a stacked plot with same x and y axis
Show older comments
Hello.
I am quite new to MatLab and the functionality compared to excel, but I wanted to do a stacked plot, where my graphs are placed above eachother.
For reference I want something where the 3 different file's graphs I've got is stacked so they look like a PXRD specta (see attached). Peaks (those 1 0 0, 1 0 2, 2 0 0 etc is not needed, just a simple way of stacking them and I suspect you can just use legends for the names?
Problem is I'm nowhere good at using MatLab and I've tried some things and I've managed to get the data inside MatLab and delete columns I don't want.
tbl1 = readtable('SrFe12O19_xy.csv');
tbl1.Properties.VariableNames = ["Degs", "Counts"]
tbl2 = readtable('Fe2O3_hematite_xy.csv');
tbl2.Properties.VariableNames = ["Degs", "Counts"]
tbl3 = readtable('SrFe12O19_Jonas_maj2021.csv');
tbl3(:, 3) = []; % Deletes column 3
tbl3.Properties.VariableNames = ["Degs", "Counts"]
Where the tbl1 and tbl2 are 660x2 table but tbl3 is 6976x2 table.

2 Comments
Adam Danz
on 19 May 2021
A bit more info is needed about your tables.
Assuming "Degs" contains the x-coordinates, are they all unique values within each table? Are they sorted in any way?
Since some tables are longer than others, the longer tables either have duplicate x-values or the shorter tables are missing x-values that are in the longer tables. Stackedplot is designed to visualize data along the same range of x-values so what's supposed to happen in the case of missing or duplicate x-coordinates?
Jonas Laursen
on 19 May 2021
Edited: Jonas Laursen
on 19 May 2021
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
