Help with graphing table into line graph
显示 更早的评论
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 个评论
Dyuman Joshi
2023-11-28
What are you plotting values against? The indices?
Do you want all the plots in a single figure? Or 4 figures for 4 plots? Or another specific setup?
Also, mention which version of MATLAB you are working with.
Christopher Kar
2023-11-28
Dyuman Joshi
2023-11-28
编辑:Dyuman Joshi
2023-11-28
"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.
回答(1 个)
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
