Scatterplot: Legend does not match color of plots

2 次查看(过去 30 天)
Hello!
I'm trying to plot correlation data onto 10 separate figures, and that works and the colors are coming out the way I want them too but I can't get the colors in the legend to match up with the color of the plots. The inputs for this code are correlation coefficient matrices. I have attached 3 of those below as mat files, and you can input them into this function. I've been trying to look this problem up but none of the solutions are quite working out for me. Any help will be appreciated. Thanks!!
function [] = plotcorr1(varargin)
% Compute number of neurons that we will compare
N = size(varargin{1}, 1);
% Compute number of matrices that we will be utilizing
K = numel(varargin);
% Initialize a cell array with space for N matrices (for N graphs)
C = cell(1, N);
% Make a matrix in each cell of size Nx1
for i = 1:N
C{i} = zeros(N, K);
end
% Put the values into the cell array
% Each cell in C represents the correlations between each neuron with neuron 1, 2, 3....
for j = 1:N
for i = 1:K
C{j}(:, i) = varargin{i}(:, j);
end
end
% Plot!
for j = 1:N
figure(j)
hold on;
for i = 1:K
x = linspace(1, N, N);
y = C{j}(:, i)';
scatter(x, y, 'o', 'filled')
legendInfo{i} = ['Matrix' num2str(i)];
legend(legendInfo);
axis([0 N+1 -.05 .2]);
title(['Correlation between Neuron ' num2str(j) ' and Other Neurons']);
xlabel('Neuron N');
ylabel('Correlation');
end
end
end

回答(1 个)

the cyclist
the cyclist 2016-6-23
I did not look at your code in detail, but I speculate that you are seeing the bug mentioned in this answer.
  1 个评论
lunaluna
lunaluna 2016-6-23
Hello! Thanks for the response! I have seen that post, but I am using the latest version of MATLAB and according to that post, this bug should already be fixed in this version. Also, I'm using MATLAB that I got from the university so it won't really let me work around the bug if it still somehow exists on my version.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by