How to insert y-coordinate into plot next to each point

I have the following code to create a subplot with two plots. I'd like to be able to insert the y-value of each data point next to the dot (for example, the top graph would have a .2 next to the second point, .31 next to the third point, and so on).
I've attached a reference photo of my graph in case it would help anyone. As a bonus, if I could avoid having the (0,0) marked with it's y-value, that'd be even better.
Thanks in advance.
total_num_attacks=[0,1,2,3,4,5];
attack_kill_array=[0,.2,.31,.39,.43,.46];
kill_chance_increase=[0,0,.38,.18,.1,.06];
max_attacks=6;
attack_kill_array_max=.51;
kill_chance_increase_max=.43;
figure()
subplot(2,1,1)
% plot(total_num_attacks,attack_kill_array,'-o','b');
plot(total_num_attacks,attack_kill_array,'-o','MarkerSize',4,'MarkerEdgeColor','b','MarkerFaceColor','b');
title('Chance of Each Attack to Result in a Kill');
xlabel('Attack')
ylabel('Chance to Kill')
xlim([0,max_attacks])
ylim([0,attack_kill_array_max])
subplot(2,1,2)
plot(total_num_attacks,kill_chance_increase,'-ko','MarkerSize',4,'MarkerEdgeColor','k','MarkerFaceColor','k');
title('Increased Chance of Attack to Kill');
xlabel('Attack')
ylabel('Kill Chance Increase')
xlim([0,max_attacks])
ylim([0,kill_chance_increase_max])

Réponses (1)

total_num_attacks=[0,1,2,3,4,5];
attack_kill_array=[0,.2,.31,.39,.43,.46];
kill_chance_increase=[0,0,.38,.18,.1,.06];
max_attacks=6;
attack_kill_array_max=.51;
kill_chance_increase_max=.43;
figure()
subplot(2,1,1)
% plot(total_num_attacks,attack_kill_array,'-o','b');
plot(total_num_attacks,attack_kill_array,'-o','MarkerSize',4,'MarkerEdgeColor','b','MarkerFaceColor','b');
i = total_num_attacks~=0 & attack_kill_array ~=0;
text(total_num_attacks(i),attack_kill_array(i),string(attack_kill_array(i)));
title('Chance of Each Attack to Result in a Kill');
xlabel('Attack')
ylabel('Chance to Kill')
xlim([0,max_attacks])
ylim([0,attack_kill_array_max])
subplot(2,1,2)
plot(total_num_attacks,kill_chance_increase,'-ko','MarkerSize',4,'MarkerEdgeColor','k','MarkerFaceColor','k');
i = total_num_attacks~=0 & kill_chance_increase ~=0;
text(total_num_attacks(i),kill_chance_increase(i),string(attack_kill_array(i)));
title('Increased Chance of Attack to Kill');
xlabel('Attack')
ylabel('Kill Chance Increase')
xlim([0,max_attacks])
ylim([0,kill_chance_increase_max])

Catégories

En savoir plus sur Surfaces, Volumes, and Polygons dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by