How to make a graph with x-axis at top and data points relative to y-axis with a straight line joined scatter?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen

Hi there, I am hoping to make a graph like this one picttures where there is a y-axis relation (not shown as this is a snip from a larger figure).
Thank you and apologies I am very new to the Matlab space!
0 Kommentare
Antworten (1)
Cameron
am 12 Jan. 2023
Bearbeitet: Cameron
am 12 Jan. 2023
You can do something like this
x = 1:10; %x data
y = x + round(rand(1,length(x)),2); %random y data
p = plot(x,y,'-o'); %plot
p.Parent.XAxisLocation = 'top'; %move the x axis to the top
p.Parent.YTick = []; %remove the y ticks
lbl = num2cell(y); %convert the number to a cell so it can be read using the text function below
text(x,y,lbl) %put the labels on the graph in the default location
You can also customize where you want the text location to be.
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!