Why is my scatter plot producing inconsistent results?
Show older comments
Im trying to make a basic scatter plot from some data that I have collected but my code is producing inconsistent results. I'm only getting 9/10 points to plot for 2017/2018 and the legend is inaccurate for 2017. I dont understand why this is happening because i literally copy and pasted the plot commands and then just changed correspomding year numbers.
clear all; close all;
pd19 = [3650];
pd18 = [3494];
pd17 = [2713];
chr19 = [2480];
chr18 = [2479];
mat17 = [2470];
cai19 = [2365];
cai18 = [2958];
cai17 = [2881];
ev19 = [2955];
ev18 = [2688];
ev17 = [2631];
jen19 = [2862];
jen18 = [2871];
jen17 = [2345];
nad19 = [2546];
nad18 = [2423];
nad17 = [2410];
sch19 = [2771];
sch18 = [2996];
sch17 = [2631];
jam19 = [2307];
jam18 = [2546];
jam17 = [2226];
sea19 = [2915];
sea18 = [3494];
bla17 = [2402];
mar19 = [2603];
mar18 = [2683];
mar17 = [2500];
x19 = [2019];
x18 = [2018];
x17 = [2017];
figure(1)
hold on
scatter(x19,pd19, 'd', 'filled')
scatter(x19, ev19,'d', 'filled')
scatter(x19, chr19,'filled')
scatter(x19, cai19,'d', 'filled')
scatter(x19, mar19, 'filled')
scatter(x19, jen19, 'd', 'filled')
scatter(x19, sea19, 'filled')
scatter(x19, sch19, 'm','d', 'filled')
scatter(x19, jam19, 'filled')
scatter(x19, nad19, 'filled')
xlim([2016 2020])
ylim([2200 3700])
title('League scoring over time')
ylabel('Points For')
xlabel('Year')
grid on
legend('pd', 'evan','chris/matt','caitlyn','mark','jenna','sean/blazic','schiesl','james','nadav')
scatter(x18,pd18, 'd', 'filled')
scatter(x18, ev18,'d', 'filled')
scatter(x18, chr18, 'filled')
scatter(x18, cai18,'d', 'filled')
scatter(x18, mar18, 'filled')
scatter(x18, jen18,'d', 'filled')
scatter(x18, sea18, 'filled')
scatter(x18, sch18,'m','d', 'filled')
scatter(x18, jam18, 'filled')
scatter(x18, nad18, 'filled')
legend('pd', 'evan','chris/matt','caitlyn','mark','jenna','sean/blazic','schiesl','james','nadav')
scatter(x17,pd17, 'd', 'filled')
scatter(x17, ev17,'d', 'filled')
scatter(x17, mat17, 'filled')
scatter(x17, cai17,'d', 'filled')
scatter(x17, mar17, 'filled')
scatter(x17, jen17,'d', 'filled')
scatter(x17, bla17, 'filled')
scatter(x17, sch17,'m','d', 'filled')
scatter(x17, jam17, 'filled')
scatter(x17, nad17, 'filled')
legend('pd', 'evan','chris/matt','caitlyn','mark','jenna','sean/blazic','schiesl','james','nadav')
hold off
Accepted Answer
More Answers (1)
Giuseppe Inghilterra
on 21 Feb 2020
Edited: Giuseppe Inghilterra
on 21 Feb 2020
1 vote
Hi,
your code is correct. ev17 and sch17 have the same value (2631). Both are plotted with diamond marker, thus they are superimposed.
I advice you to use a different marker for each scatter plot of same year. In this way a marker identifies a player. Moreover, if you want that legend is accurate in terms of marker and color, you also have to fix color for each scatter plot in order to have same marker and same color for same player.
From here you can get all types of marker that you can use:
Hope this helps.
1 Comment
Lakerpurp24
on 21 Feb 2020
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!