How to make line graph for Y vs X?

Dear all,
I want to plot Y variable against X. I have seven column where first column (X) represents different years and rest 6 column (Y1, Y2......, Y6) represent water level value at different percentile (from 5th to 99th) respectively. I just want to plot each Y variable against X in one graph.
Can anyone help me, please? I am at the very beginning level.
Thanks
Bishwajit
2010.0 0.00990000 0.02200000 0.03760000 0.05240000 0.06350000 0.07810000
2020.0 0.02830000 0.04250000 0.06790000 0.09340000 0.11050000 0.12750000
2030.0 0.05400000 0.07630000 0.11000000 0.14090000 0.16550000 0.19590000
2040.0 0.07730000 0.10570000 0.14760000 0.18810000 0.22100000 0.25130000
2050.0 0.08260000 0.13000000 0.18810000 0.24320000 0.28990000 0.33200000
2060.0 0.10420000 0.16200000 0.23500000 0.30740000 0.35020000 0.40470000
2070.0 0.11090000 0.18040000 0.28040000 0.36750000 0.42990000 0.48520000
2080.0 0.11330000 0.20350000 0.31200000 0.42620000 0.51790000 0.60280000
2090.0 0.12790000 0.21760000 0.35260000 0.47490000 0.57430000 0.68680000
2100.0 0.12810000 0.25180000 0.39090000 0.52390000 0.63510000 0.75860000

 Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 15 Oct 2019
Edited: KALYAN ACHARJYA on 15 Oct 2019
data=[2010.0 0.00990000 0.02200000 0.03760000 0.05240000 0.06350000 0.07810000
2020.0 0.02830000 0.04250000 0.06790000 0.09340000 0.11050000 0.12750000
2030.0 0.05400000 0.07630000 0.11000000 0.14090000 0.16550000 0.19590000
2040.0 0.07730000 0.10570000 0.14760000 0.18810000 0.22100000 0.25130000
2050.0 0.08260000 0.13000000 0.18810000 0.24320000 0.28990000 0.33200000
2060.0 0.10420000 0.16200000 0.23500000 0.30740000 0.35020000 0.40470000
2070.0 0.11090000 0.18040000 0.28040000 0.36750000 0.42990000 0.48520000
2080.0 0.11330000 0.20350000 0.31200000 0.42620000 0.51790000 0.60280000
2090.0 0.12790000 0.21760000 0.35260000 0.47490000 0.57430000 0.68680000
2100.0 0.12810000 0.25180000 0.39090000 0.52390000 0.63510000 0.75860000];
for i=2:7
plot(data(:,1),data(:,i));
hold on;
end
456.png

3 Comments

Dear Mr. Kalyan,
Thanks for your quick help. I want to put the legend, axis label, axis tick for the plot with the following code. But, it's not working. Can you correct my code, please?
Moreover, I want to show the point of values on each line. Can you help me?
Thanks in advance!
>> data=[2010.0 0.00990000 0.02200000 0.03760000 0.05240000 0.06350000 0.07810000
2020.0 0.02830000 0.04250000 0.06790000 0.09340000 0.11050000 0.12750000
2030.0 0.05400000 0.07630000 0.11000000 0.14090000 0.16550000 0.19590000
2040.0 0.07730000 0.10570000 0.14760000 0.18810000 0.22100000 0.25130000
2050.0 0.08260000 0.13000000 0.18810000 0.24320000 0.28990000 0.33200000
2060.0 0.10420000 0.16200000 0.23500000 0.30740000 0.35020000 0.40470000
2070.0 0.11090000 0.18040000 0.28040000 0.36750000 0.42990000 0.48520000
2080.0 0.11330000 0.20350000 0.31200000 0.42620000 0.51790000 0.60280000
2090.0 0.12790000 0.21760000 0.35260000 0.47490000 0.57430000 0.68680000
2100.0 0.12810000 0.25180000 0.39090000 0.52390000 0.63510000 0.75860000];
for i=2:7
plot(data(:,1),data(:,i));
hold on;
end
figure('units','normalized','position',[0.1 0.1 0.8 0.5]);
axes('units','normalized','position',[0.07 0.08 0.9 0.9]);
set(gca,'xlim',[2010 2100],'xtick',[2010.30:2100],'xticklabel',[2010:30:2100]);
set(gca,'ylim',[-1 3],'ytick',[-1.0.2:3],'yticklabel',[-1:1:3])
set(gca,'fontsize',14,'fontweight','bold');
xlabel('year','fontsize',16,'fontweight','bold');
ylabel('Month','fontsize',16,'fontweight','bold');
set(gca,'ylim',[-1 3],'ytick',[-1.0.2:3],'yticklabel',[-1:1:3])
Hi
Can anyone help me to put the legend inside the plot? I tried with the above code, didn't work.
Thanks in advance
KALYAN ACHARJYA
KALYAN ACHARJYA on 15 Oct 2019
Edited: KALYAN ACHARJYA on 15 Oct 2019
There are numerus answered questions related to the same(legends, ticks etc) . Try to implement one by one, if you have any specific issue, let me know.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!