problem in plot with conditions
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hi,
I have table with 2000 rows and 3 columns , each sum(row) either be 1 or 2 or 3
I want to map that as graph. where each row represents user , if sum(row) of uers was 3, then I can know that user is active in online community. I think if got such graph ,it will be important in my work, but if no. of rows is 2000 how the graph will be?
Let c1 is first_column , c2 is seond_column, c3 is third_column
i.e for each row:
if c1=1 , then plot (no_row,1,’*’, ‘color’,’b’)
if c2=1 , then plot (no_row,2,’*’, ‘color’,’b’)
if c3=1 , then plot (no_row,3,’*’, ‘color’,’b’)
if c1=1 and c2=1 then plot (no_row,1,’*’, ‘color’,’g’)
plot (no_row,2,’*’, ‘color’,’g’)
if c1=1 and c3=1 then plot (no_row,1,’*’, ‘color’,’g’)
plot (no_row,3,’*’, ‘color’,’g’)
if c1=2 and c3=1 then plot (no_row,1,'*’, ‘color’,’g’)
plot (no_row,3,’*’, ‘color’,’g’)
if c1=1 and c2=1 and c3=1 then plot (no_row,1,’*’, ‘color’,’r’)
plot (no_row,2,’*’, ‘color’,’r’)
plot (no_row,3,’*’, ‘color’,’r’)
thanks in advance
2 comentarios
Walter Roberson
el 29 de Abr. de 2013
With your tests arranged like that, if all three columns are 1, then the row would end up getting plotted in 'b', 'g', and 'r'. I don't think that was your intention ?
To check: (0,2,1) and (0,1,2) are also possible? Can any one column contain a 3 ?
Respuestas (1)
Walter Roberson
el 29 de Abr. de 2013
coltab = [1 1 1; %no activity
0 0 1; %one period
0 1 0; %two periods
1 0 0]; %three periods
logtab = YourTable > 0;
colidx = 1 + sum(logtab, 2);
rowview = repmat([1 2 3], size(logtab,1), 1) .* logtab;
rowview(~rowview) = NaN;
pointsize = 8;
scatter(1:size(rowview,1), rowview .', pointsize, coltab(colidx, :));
6 comentarios
Walter Roberson
el 29 de Abr. de 2013
Your sample code had
if c1=2 and c3=1
Anyhow, if you do not need to calculate logtab then you can replace logtab with YourTable in the code that follows.
I understand about the scatter problem; I need to think more about the best way to fix it.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!