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
댓글 수: 0
답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!