Problem in Visualising line plots and color coding the lines
古いコメントを表示
I have 100 sets of probability data which ranges from 1E-4 to 1E-6 that I would like to plot as line graphs. To enhance the visualization, I plan to take the logarithm of the probabilities and color code by the log of probability that it would occur. Additionally, I aim to sort the lines so that the highest probabilities are plotted on top for better visibility. However, the current MATLAB code I have attempted is not yielding the desired outcome. I kindly request your assistance in identifying any errors and providing guidance on visualizing the data more effectively.
% Set the range of random numbers
minValue = 1E-6;
maxValue = 1E-4;
% Generate 100 random numbers
total_probability = minValue + (maxValue - minValue) * rand(1, 100);
% Take the logarithm of the probabilities
log_probabilities = log(total_probability);
% Sort the probabilities in descending order
[sorted_probabilities, sorted_indices] = sort(log_probabilities, 'descend');
% Sort the original data accordingly
sorted_data = total_probability(sorted_indices);
% Plot the line plots with color coding based on log probabilities
figure;
hold on;
for i = 1:length(sorted_data)
color_value = sorted_probabilities(i) / max(sorted_probabilities);
plot(sorted_data(i), 'Color', [color_value 0 0]);
end
hold off;
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
