Which graph is recommended?
2 views (last 30 days)
Show older comments
Hi, I have a matrix (attached) and each row constitutes a 2 unique numbers that I would like to plot (coloumn order matters). For example, if the row is [1 4], I would like to plot for all the [1 4] together. At first, I thought of using a scatterplot but it would not be able to show me how many [1 4] there are when i plot column 1 as x axis, and column 2 as y axis as the points stack onto each other. The goal is to create a visual representation of how many rows fit the criteria when column 1 is plotted as x axis, and column 2 is plotted as y axis, sort of like a heat map, without the timestamps. For example, if there are 4 rows that have [1 4], the graph should depict that there are 4 of them. Are there any specific graphs that i can consider to achieve this? Histogram2 works but I would prefer a 2D graph.
Many thanks!
0 Comments
Answers (1)
Star Strider
on 16 Apr 2020
I would do something like this for the plot:
D = load('localcombi.mat');
localcombi = D.localcombi;
[Ur,~,ix] = unique(localcombi, 'rows'); % Unique Rows
k = accumarray(ix,1); % Counts
Counts = table(Ur,k,'VariableNames',{'Unique_Rows','Count'}); % Results Table
figure
stem3(Ur(:,1), Ur(:,2), k) % Results Using ‘stem3’
grid on
xlabel('Column 1')
ylabel('Column 2')
zlabel('Count')
I am not certain what you want for the plot. This is the only way I can think of (other than scatter3) to present the column coordinates and the numbers of each unique pair.
.
0 Comments
See Also
Categories
Find more on Line Plots 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!