how to change the type of points for a plot

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.

 Accepted Answer

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 Comments

Thank you for your answer but that does not answer my problem.
In my plot, I have different points with x and y and I want in my plot a number for each point.
plot(x, y, '*b', 'MarkerSize', 6)
My pleasure!
My posted code is an illustration of how to do what you described, since I do not have your data, or an example of what you want to plot, or how to label a ‘trial’.
Also:
plot(x, y, '*b', 'MarkerSize', 6)
plots a blue asterisk at the points. You originally wrote that you did not want to plot points.
Please note that I cannot plot images of code or data, and I have no idea how to identify a ‘trial’ from the image you posted. That is still undefined.
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
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.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

JR
on 9 Oct 2020

Commented:

on 9 Oct 2020

Community Treasure Hunt

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

Start Hunting!