Help with graphing table into line graph
5 views (last 30 days)
Show older comments
Hello,
I am trying to graph a table into a line graph. The table is 4 columns: Outside Diameter(in), Wall Thickness(in), Stress(PSI), and Safety Factor.
I am having trouble formatting the table into a line graph that can show all the values.
The safety factor values are so low that the line is barely visibile to nonexistent.
What would be the proper way to format this? Is there a function for something like this?
Thank you
3 Comments
Dyuman Joshi
on 28 Nov 2023
Edited: Dyuman Joshi
on 28 Nov 2023
"Ideally, I was looking a single graph/plot that can showcase all 4 columns accurately."
If the scaling of the 4 data-sets are quite different, one option is to use log scales on yaxis. However, this would not work as expected if there is negative or 0 values in the data.
Answers (1)
Peter Perkins
on 28 Nov 2023
This spreadsheet is kind of messed up, and I will let you figure out how best to read it in. Given that, it seems like stackedplot would be useful.
t = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1554152/Data.xlsx");
t.OD_in_ = [1;1;1;1;1.25;1.25;1.25;1.25;1.5;1.5;1.5;1.5;1.75;1.75;1.75;1.75];
t.WT_in_ = [3/25;5/32;3/16;1/4;3/25;5/32;3/16;1/4;3/25;5/32;3/16;1/4;3/25;5/32;3/16;1/4];
t
stackedplot(t)
This uses a table. You might also want to look at timetables to plot vs. time, but I actually don't think that's what you are doing. In fact, it seems like you really want a surface plot of x and SF vs. OD and WT. But that's not what you described.
0 Comments
See Also
Categories
Find more on Line Plots 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!