How to make a graph with x-axis at top and data points relative to y-axis with a straight line joined scatter?

5 vues (au cours des 30 derniers jours)
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!

Réponses (1)

Cameron
Cameron le 12 Jan 2023
Modifié(e) : Cameron le 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.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by