How to make a graph with x-axis at top and data points relative to y-axis with a straight line joined scatter?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Cameron
il 12 Gen 2023
Modificato: Cameron
il 12 Gen 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.
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!