how to change the type of points for a plot

8 Ansichten (letzte 30 Tage)
JR
JR am 9 Okt. 2020
Kommentiert: Star Strider am 9 Okt. 2020
Hello,
I have a plot with different points (corresponding to different trials) and I would like to modify the type of points in my plot.
I would like to put the number of each row of my table instead of a cross or a dot.
How can I do this kind of thing?
Thank you in advance.

Akzeptierte Antwort

Star Strider
Star Strider am 9 Okt. 2020
This should get you started:
x = 1:10; % Create Data
y = rand(size(x)); % Create Data
figure
plot(x, y, '.', 'Color','none') % Plot Colourless Dots
grid
datalbl = compose('%d',x); % Create Point Labels
text(x, y, datalbl, 'HorizontalAlignment','center', 'VerticalAlignment','middle') % ‘Plot’ Point Labels
.
  4 Kommentare
JR
JR am 9 Okt. 2020
Thank you again!
In my image, we have the x and y of my data (column 1 = x; column 2 = y) and each line corresponds to a point (a couple of x and y).
Instead of blue asteriks, I would like to have the number of each line (1, 2, 3...)
There is the representation of my data on the plot with the asterik for each point
Star Strider
Star Strider am 9 Okt. 2020
My pleasure!
Try this:
x = rand(1,50); % Create ‘x’ Data
y = rand(size(x)); % Create ‘y’ Data
Trial = 1:numel(x); % Create ‘Trial’ Identifiers
figure
plot(x, y, '.', 'Color','none') % Plot Colourless Dots
grid
datalbl = compose('%d',Trial); % Create Point Labels
text(x, y, datalbl, 'HorizontalAlignment','center', 'VerticalAlignment','middle', 'FontSize',8) % ‘Plot’ Point Labels
It is a slight variation on my earlier code. It should be straightforward for you to adapt it to your data.
Experiment with it to get the result you want.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by