How can i draw this in a plot
Show older comments
I am trying to draw this plot which have x axis value increase and then decrease as below

but when i do that in matlab it return the values as below

x = [ 355 390 401 410 430 420 415 415 400]
y = [ 190 210 220 225 225 221 220 220 205]
Please need your help in make this plot
Answers (1)
Jan
on 4 Feb 2018
Maybe:
x = [ 355 390 401 410 430 420 415 415 400]
y = [ 190 210 220 225 225 221 220 220 205]
plot(x)
hold on
plot(y)
4 Comments
Tareq Al-Ma'aiteh
on 4 Feb 2018
Edited: Tareq Al-Ma'aiteh
on 4 Feb 2018
Jan
on 4 Feb 2018
@Tareq: You have provided two data sets. Then my first guess is that both are relevant. You have posted a diagram with 3 lines, therefore I assumed, that your questions concerns multiple lines in one diagram. I have provided a code to draw the two lines in one diagram.
Now you explain, that you want one line also. It is trivial not to run the three commands I had posted, but the wanted one only:
plot(y)
Do you want to set the Y-limits also?
ylim([170, 230])
Or does the title matter also?
title('Y')
Please explain more clearly, what you want.
Tareq Al-Ma'aiteh
on 4 Feb 2018
Jan
on 4 Feb 2018
x = [ 355 390 401 410 430 420 415 415 400]
y = [ 190 210 220 225 225 221 220 220 205]
plot(y)
set(gca, 'XTick', 1:length(x), 'XTickLabel', sprintfc('%g', x))
If this solves your problem, the question was: "How to set the XTickLabels to values specified by the user?"
Categories
Find more on Annotations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!