Clarity when you have multiple plots

2 ビュー (過去 30 日間)
Raushan
Raushan 2022 年 8 月 30 日
コメント済み: Raushan 2022 年 9 月 2 日
Hey guys! I have one .csv file containing 8 columns. I want to plot 8th column (Time200) on x axis and remaining 7 columns on y axis. I did that but plots look messy, I mean its hard to interprate the difference among graphs. Is there any way to make these plots clear or interpratable. I will appreciate any kind of help. Thank you.

採用された回答

Image Analyst
Image Analyst 2022 年 8 月 30 日
編集済み: Image Analyst 2022 年 9 月 2 日
How about this:
% Initialization Steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
data = importdata('Plotdata.csv');
timeData = data.data;
columnHeaders = data.colheaders;
[rows, columns] = size(timeData);
% Sort by column 8 in ascending order
timeData = sortrows(timeData, 8)
t = timeData(:, end); % Times are the last column.
% Make up colors for the plot lines
plotColors = jet(columns - 1);
% Plot columns 1 to columns-1
for col = 1 : columns - 1
y = timeData(:, col);
plot(t, y, '.-', 'Color', plotColors(col, :), 'LineWidth', 2, 'MarkerSize', 30);
hold on;
end
xlabel('Time', 'FontSize',fontSize);
ylabel('y', 'FontSize',fontSize);
grid on;
hold off;
legend(columnHeaders(1:end-1), 'Location', 'southwest')
[EDIT] plot with original data removed at poster's request.
  3 件のコメント
Image Analyst
Image Analyst 2022 年 9 月 2 日
As requested, I've changed my program to not use your data, which looked pretty generic by the way. I wrote a program to create some plots and run it with both unsorted times (like you have) and with the times sorted. The results are shown below:
% Demo by Image Analyst
% Initialization Steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
% data = importdata('Plotdata.csv');
% timeData = data.data;
[t, timeData, columnHeaders] = CreateSampleData();
% columnHeaders = data.colheaders;
[rows, columns] = size(timeData);
promptMessage = sprintf('Do you want to sort the times?');
titleBarCaption = 'Sort?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Yes', 'No', 'Quit', 'Yes');
if contains(buttonText, 'Quit', 'IgnoreCase', true)
return; % or break or continue.
elseif contains(buttonText, 'Yes', 'IgnoreCase', true)
% Sort time in ascending order
t = sort(t);
plotTitle = 'Using sorted times';
else
plotTitle = 'Using unsorted times';
end
% Make up colors for the plot lines
plotColors = jet(columns);
% Plot columns
for col = 1 : columns
y = timeData(:, col);
plot(t, y, '.-', 'Color', plotColors(col, :), 'LineWidth', 2, 'MarkerSize', 30);
hold on;
end
title(plotTitle, 'FontSize', fontSize);
xlabel('Time', 'FontSize',fontSize);
ylabel('y', 'FontSize',fontSize);
grid on;
hold off;
legend(columnHeaders(1:end), 'Location', 'southwest')
%=============================================================================================
function [t, timeData, columnHeaders] = CreateSampleData()
rows = 15;
columns = 8;
columnHeaders = cell(columns, 1);
baseCurve = linspace(0.17, 0.10, rows)';
t = 1 : rows;
% Scramble order of the times, like the original poster had.
randomOrder = randperm(length(t));
t = t(randomOrder);
% Add noise and lift
for col = 1 : columns
thisCol = baseCurve + .1 * col + 0.05 * rand(rows, 1);
timeData(:, col) = thisCol;
columnHeaders{col} = sprintf('Time %d', col);
end
end
Raushan
Raushan 2022 年 9 月 2 日
Thank you very much sir! It helps me a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeArgument Definitions についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by