'Scatterplot in Matlab: how to improve visualisation

Consider the following Matlab code creating a scatterplot, where I essentially draw horizontal lines of random numbers.

clear
rng default
s1=66;

%(1) Create vectors of random numbers with different dimensions and store them in the cell array K_id 
%(some cells are empty on purpose)
dim=randi([1 1000],1000,1);
K_id=cell(s1,1);
K_id{1}=(1.99-0.01).*rand(dim(1),1) + 0.01;
for j=12:s1
    K_id{j}=(1.99-0.01).*rand(dim(j),1) + 0.01;
end

%(2) Plot
for j=1:s1
    scatter(K_id{j},j*ones(size(K_id{j},1),1));
    hold on
end

Question 1: How can I increase the distance between every two lines, so that each line can be seen better, separated from the others? I am not interested in the y-axis. I have tried to increase the height at which each line is plotted, but the effect does not change because Matlab rescales everything.

Question 2: Next to each line, I would like to attach a label. These are the labels:

p_temp=(0:0.1:1).';
[ca, cb] = ndgrid(p_temp, p_temp);
p_grid=[ca(:) cb(:)];  
p_grid(p_grid(:,1)+p_grid(:,2)>1,:)=[];

Specifically, the label of the line corresponding to K_id{j} is p_grid(j,:). For example, the label for K_id{1} is [0,0].

The problem is that there are too many lines and, hence, too many labels.

One idea could be to reduce the number of labels as follows. From the structure of p_grid, note that from row 1 to 11 p_grid(:,2)=0 and p_grid(:,1) goes from 0 to 1 at intervals of 0.1; from row 12 to 21, p_grid(:,2)=0.1 and p_grid(:,1) goes from 0 to 0.9 at intervals of 0.1; and so on.

Therefore, it would be sufficient for me to just insert the extreme labels: [0 0], [0 1], [0.1 0], [0.1 0.9], [0.2 0], [0.2 0.8], etc.

But how can I do that?

Or, do you have other suggestions to improve visualisation?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source