Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Labeling points in order in a plot

Tags:

plot

matlab

I have two vectors representing the location of points (x,y) that I'd like to plot.

I know how to plot them, but I'd also like to label them 1, 2, 3, 4... with labels visible on the plot. The labels represent their order in the vector.

like image 982
Jamie Banks Avatar asked Nov 10 '10 00:11

Jamie Banks


People also ask

How do you label coordinates?

By default, the x coordinate of x axis labels is the mid-point of the frame coordinates. For example, the default frame coordinates are (15,20) and (85,90) which results in a default x coordinate of (15+85)/2 = 50. The y coordinate is determined by the LABEL DISPLACEMENT command.

What is plot Labelling?

A labeled scatter plot is a data visualization that displays the values of two different variables as points. The data for each point is represented by its horizontal (x) and vertical (y) position on the visualization. A text label is used to show the meaning of each data point.

How to add labels to scatterplot points in base R?

To add labels to scatterplot points in base R you can use the text () function, which uses the following syntax: text (x, y, labels, …) The following code shows how to label a single point on a scatterplot in base R: The following code shows how to label every point on a scatterplot in base R:

How do you label a point on the plane?

Our x-coordinate determines that our point will be: Labeling a point: Given a point on the plane, we can determine its x- and y-coordinates based on the respective horizontal and vertical distances from the origin. We essentially do the opposite of what we do when we plot a point.

How to label data point on multi line graph using matplotlib?

Label data point on multi line graph using Matplotlib 0 Annotating local minima below a given threshold of (y) using matplotlib and pandas 3 Python matplotlib: add count number on top of the bar 3 Plot and annotate from DataFrame with MultiIndex and multiple columns

How to label the points on a graph in R?

The points can be labeled using various methods available in base R and by incorporating some external packages. The ggplot () method can be used in this package in order to simulate graph customizations and induce flexibility in graph plotting.


1 Answers

Here's one way to do this:

p = rand(10,2); labels = cellstr( num2str([1:10]') );  %' # labels correspond to their order  plot(p(:,1), p(:,2), 'rx') text(p(:,1), p(:,2), labels, 'VerticalAlignment','bottom', ...                              'HorizontalAlignment','right') 

alt text

like image 90
Amro Avatar answered Sep 23 '22 17:09

Amro