Plotting multiple datasets on one plot
I have a set of data for three replicate simulations: run0-run2, these consist of .dat files at a set time interval (here, every 100ns until final time 500ns).
I would like to plot these all on one plot but with a different colour gradient from darker to lighter e.g.
Run0 with a blue gradient dark to light as time increases.
Run1 with a green gradient dark to light as time increases.
Run2 with a red gradient dark to light as time increases.
I created the MATLAB script below but during testing, only the red plots would show up.
Combining into one for loop doesn’t work as I tried that already.
Any help would be greatly apreciated.
Code below and attached.
r0_f100=readmatrix (‘run0_test_fluct-100ns.dat’);
r0_f200=readmatrix (‘run0_test_fluct-200ns.dat’);
r0_f300=readmatrix (‘run0_test_fluct-300ns.dat’);
r0_f400=readmatrix (‘run0_test_fluct-400ns.dat’);
r0_f500=readmatrix (‘run0_test_fluct-500ns.dat’);
x_0=r0_f100(:,1);
y_0=[r0_f100(:,2),r0_f200(:,2),r0_f300(:,2),r0_f400(:,2),r0_f500(:,2)];
r1_f100=readmatrix (‘run1_test_fluct-100ns.dat’);
r1_f200=readmatrix (‘run1_test_fluct-200ns.dat’);
r1_f300=readmatrix (‘run1_test_fluct-300ns.dat’);
r1_f400=readmatrix (‘run1_test_fluct-400ns.dat’);
r1_f500=readmatrix (‘run1_test_fluct-500ns.dat’);
x_1=r1_f100(:,1);
y_1=[r1_f100(:,2),r1_f200(:,2),r1_f300(:,2),r1_f400(:,2),r1_f500(:,2)];
r2_f100=readmatrix (‘run2_test_fluct-100ns.dat’);
r2_f200=readmatrix (‘run2_test_fluct-200ns.dat’);
r2_f300=readmatrix (‘run2_test_fluct-300ns.dat’);
r2_f400=readmatrix (‘run2_test_fluct-400ns.dat’);
r2_f500=readmatrix (‘run2_test_fluct-500ns.dat’);
x_2=r2_f100(:,1);
y_2=[r2_f100(:,2),r2_f200(:,2),r2_f300(:,2),r2_f400(:,2),r2_f500(:,2)];
num_plots = 5;
colors = linspace(0.5, 1, num_plots)’;
figure
hold on
for i=1:num_plots
plot(x_0, y_0(:,i), ‘color’, [0 0 colors(i)]);
end
for i=1:num_plots
plot(x_1, y_1(:,i), ‘color’, [0 colors(i) 0]);
end
for i=1:num_plots
plot(x_2, y_2(:,i), ‘color’, [colors(i) 0 0]);
end
xlabel (‘Residue No.’); ylabel (‘RMSF / Å’);
ax = gca;
fig=gcf;
fig.Position(3:4)=[800,600];
fig.Color=[0.95 0.95 0.95];
ax.Color=[0.8 0.8 0.8];
hold off
%exportgraphics(fig,’test_RMSF.jpg’,’Resolution’,300);I have a set of data for three replicate simulations: run0-run2, these consist of .dat files at a set time interval (here, every 100ns until final time 500ns).
I would like to plot these all on one plot but with a different colour gradient from darker to lighter e.g.
Run0 with a blue gradient dark to light as time increases.
Run1 with a green gradient dark to light as time increases.
Run2 with a red gradient dark to light as time increases.
I created the MATLAB script below but during testing, only the red plots would show up.
Combining into one for loop doesn’t work as I tried that already.
Any help would be greatly apreciated.
Code below and attached.
r0_f100=readmatrix (‘run0_test_fluct-100ns.dat’);
r0_f200=readmatrix (‘run0_test_fluct-200ns.dat’);
r0_f300=readmatrix (‘run0_test_fluct-300ns.dat’);
r0_f400=readmatrix (‘run0_test_fluct-400ns.dat’);
r0_f500=readmatrix (‘run0_test_fluct-500ns.dat’);
x_0=r0_f100(:,1);
y_0=[r0_f100(:,2),r0_f200(:,2),r0_f300(:,2),r0_f400(:,2),r0_f500(:,2)];
r1_f100=readmatrix (‘run1_test_fluct-100ns.dat’);
r1_f200=readmatrix (‘run1_test_fluct-200ns.dat’);
r1_f300=readmatrix (‘run1_test_fluct-300ns.dat’);
r1_f400=readmatrix (‘run1_test_fluct-400ns.dat’);
r1_f500=readmatrix (‘run1_test_fluct-500ns.dat’);
x_1=r1_f100(:,1);
y_1=[r1_f100(:,2),r1_f200(:,2),r1_f300(:,2),r1_f400(:,2),r1_f500(:,2)];
r2_f100=readmatrix (‘run2_test_fluct-100ns.dat’);
r2_f200=readmatrix (‘run2_test_fluct-200ns.dat’);
r2_f300=readmatrix (‘run2_test_fluct-300ns.dat’);
r2_f400=readmatrix (‘run2_test_fluct-400ns.dat’);
r2_f500=readmatrix (‘run2_test_fluct-500ns.dat’);
x_2=r2_f100(:,1);
y_2=[r2_f100(:,2),r2_f200(:,2),r2_f300(:,2),r2_f400(:,2),r2_f500(:,2)];
num_plots = 5;
colors = linspace(0.5, 1, num_plots)’;
figure
hold on
for i=1:num_plots
plot(x_0, y_0(:,i), ‘color’, [0 0 colors(i)]);
end
for i=1:num_plots
plot(x_1, y_1(:,i), ‘color’, [0 colors(i) 0]);
end
for i=1:num_plots
plot(x_2, y_2(:,i), ‘color’, [colors(i) 0 0]);
end
xlabel (‘Residue No.’); ylabel (‘RMSF / Å’);
ax = gca;
fig=gcf;
fig.Position(3:4)=[800,600];
fig.Color=[0.95 0.95 0.95];
ax.Color=[0.8 0.8 0.8];
hold off
%exportgraphics(fig,’test_RMSF.jpg’,’Resolution’,300); I have a set of data for three replicate simulations: run0-run2, these consist of .dat files at a set time interval (here, every 100ns until final time 500ns).
I would like to plot these all on one plot but with a different colour gradient from darker to lighter e.g.
Run0 with a blue gradient dark to light as time increases.
Run1 with a green gradient dark to light as time increases.
Run2 with a red gradient dark to light as time increases.
I created the MATLAB script below but during testing, only the red plots would show up.
Combining into one for loop doesn’t work as I tried that already.
Any help would be greatly apreciated.
Code below and attached.
r0_f100=readmatrix (‘run0_test_fluct-100ns.dat’);
r0_f200=readmatrix (‘run0_test_fluct-200ns.dat’);
r0_f300=readmatrix (‘run0_test_fluct-300ns.dat’);
r0_f400=readmatrix (‘run0_test_fluct-400ns.dat’);
r0_f500=readmatrix (‘run0_test_fluct-500ns.dat’);
x_0=r0_f100(:,1);
y_0=[r0_f100(:,2),r0_f200(:,2),r0_f300(:,2),r0_f400(:,2),r0_f500(:,2)];
r1_f100=readmatrix (‘run1_test_fluct-100ns.dat’);
r1_f200=readmatrix (‘run1_test_fluct-200ns.dat’);
r1_f300=readmatrix (‘run1_test_fluct-300ns.dat’);
r1_f400=readmatrix (‘run1_test_fluct-400ns.dat’);
r1_f500=readmatrix (‘run1_test_fluct-500ns.dat’);
x_1=r1_f100(:,1);
y_1=[r1_f100(:,2),r1_f200(:,2),r1_f300(:,2),r1_f400(:,2),r1_f500(:,2)];
r2_f100=readmatrix (‘run2_test_fluct-100ns.dat’);
r2_f200=readmatrix (‘run2_test_fluct-200ns.dat’);
r2_f300=readmatrix (‘run2_test_fluct-300ns.dat’);
r2_f400=readmatrix (‘run2_test_fluct-400ns.dat’);
r2_f500=readmatrix (‘run2_test_fluct-500ns.dat’);
x_2=r2_f100(:,1);
y_2=[r2_f100(:,2),r2_f200(:,2),r2_f300(:,2),r2_f400(:,2),r2_f500(:,2)];
num_plots = 5;
colors = linspace(0.5, 1, num_plots)’;
figure
hold on
for i=1:num_plots
plot(x_0, y_0(:,i), ‘color’, [0 0 colors(i)]);
end
for i=1:num_plots
plot(x_1, y_1(:,i), ‘color’, [0 colors(i) 0]);
end
for i=1:num_plots
plot(x_2, y_2(:,i), ‘color’, [colors(i) 0 0]);
end
xlabel (‘Residue No.’); ylabel (‘RMSF / Å’);
ax = gca;
fig=gcf;
fig.Position(3:4)=[800,600];
fig.Color=[0.95 0.95 0.95];
ax.Color=[0.8 0.8 0.8];
hold off
%exportgraphics(fig,’test_RMSF.jpg’,’Resolution’,300); multiple datasets, plotting MATLAB Answers — New Questions