How to make a graph with x-axis at top and data points relative to y-axis with a straight line joined scatter?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos

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 comentarios
Respuestas (1)
Cameron
el 12 de En. de 2023
Editada: Cameron
el 12 de En. de 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.
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!