0
votes

I have generated some random population using rand of size 50 x 2, with a dimension of 2. This population is evaluated giving some values call fitness for each individuals in the population. Now i want to plot all the individuals in the population with their fitness values, in such a way that you will have an individual as a cross with its fitness value beside it. I know how to plot the individuals using scatter plot and the individuals are shown on the matlab plot as crosses, but i don't now how i can show their fitness values beside them.

Example:

individuals(Pop)     fitness values
  x      y
  3      5                 7
  4      6                 4
  1      3                 0
  3      0                10
.....
and on up the the 50th

Now i want to plot these with their fitness values shown beside them on a matlab figure For if individual with coordinates (3, 5) is plotted and shown on the plot as 'x', i want the fitness value 7 to be size it, like this: x(7) or x7 or 7x or any form, but i just want to know the this particular individual (3, 5) fitness is 7 on the matlab plot.The fitness is also plotted as contour line, but i want the values shown on the plot.

I have searched here and google and i get suggestion like using num2str and using text for plotting which i try but did not work for me. Does any one have an idea of how i can do this please? Matlab code that does it will be welcome.

1

1 Answers

0
votes

I have solved this issue. I use num2str and apply it on the text command and it has worked.

here is what i did

fv is the fitness values in my example
strValues = strtrim(cellstr(num2str([fv],'(%d)')));
text(co(:,1), co(:,2),strValues,'VerticalAlignment','top');

the co are the points of the individuals(Pop) in my example.