Group Data for one Legend in Figure of Multiple SubPlots
Hi All,
I am working with several instances that I want to plot data for each with their own data set. For example I have four plots with their own respective signals I need to look at and for multiple instances. Each instance is comprised of several variations that I need to be of the same color. In each plot each instance is colored differently but each data set of variations is one color based on instance. I have been scouring the internet for help on this but I can’t seem to get any solution to this issue.
What i would like to do is have one legend (and yes I know i could just add a legend to one of my subplots and move it) that only has the different instances and their respective colors without adding in all of the variations within the data set. I have a loop set up to plot 5 variations per instance and I was hoping to loop this through instances that use different files. Below is kind of the code I’ve been working around and trying to make work. Its just a section for ease, but basically lets say I have 5 instances and each has 5 variations, I can plot them and ensure each variation is the same color so i have 5 different colors on the plots, but I want a legent just to show the 5 instances in their respective colors and not 25 for evry line.
Please help me out here, I am starting to go nuts and found some very terrible ways of diong this by hand which aren’t applicable at all.
for z = 1:num files;
subplot(1,2,2);
hold on
grid on;
for i = 1:5
plot(z) = plot(StartA(:,i),AMA_1(:,i),color)
end
end
legend(plot(1),plot(2), etc…Hi All,
I am working with several instances that I want to plot data for each with their own data set. For example I have four plots with their own respective signals I need to look at and for multiple instances. Each instance is comprised of several variations that I need to be of the same color. In each plot each instance is colored differently but each data set of variations is one color based on instance. I have been scouring the internet for help on this but I can’t seem to get any solution to this issue.
What i would like to do is have one legend (and yes I know i could just add a legend to one of my subplots and move it) that only has the different instances and their respective colors without adding in all of the variations within the data set. I have a loop set up to plot 5 variations per instance and I was hoping to loop this through instances that use different files. Below is kind of the code I’ve been working around and trying to make work. Its just a section for ease, but basically lets say I have 5 instances and each has 5 variations, I can plot them and ensure each variation is the same color so i have 5 different colors on the plots, but I want a legent just to show the 5 instances in their respective colors and not 25 for evry line.
Please help me out here, I am starting to go nuts and found some very terrible ways of diong this by hand which aren’t applicable at all.
for z = 1:num files;
subplot(1,2,2);
hold on
grid on;
for i = 1:5
plot(z) = plot(StartA(:,i),AMA_1(:,i),color)
end
end
legend(plot(1),plot(2), etc… Hi All,
I am working with several instances that I want to plot data for each with their own data set. For example I have four plots with their own respective signals I need to look at and for multiple instances. Each instance is comprised of several variations that I need to be of the same color. In each plot each instance is colored differently but each data set of variations is one color based on instance. I have been scouring the internet for help on this but I can’t seem to get any solution to this issue.
What i would like to do is have one legend (and yes I know i could just add a legend to one of my subplots and move it) that only has the different instances and their respective colors without adding in all of the variations within the data set. I have a loop set up to plot 5 variations per instance and I was hoping to loop this through instances that use different files. Below is kind of the code I’ve been working around and trying to make work. Its just a section for ease, but basically lets say I have 5 instances and each has 5 variations, I can plot them and ensure each variation is the same color so i have 5 different colors on the plots, but I want a legent just to show the 5 instances in their respective colors and not 25 for evry line.
Please help me out here, I am starting to go nuts and found some very terrible ways of diong this by hand which aren’t applicable at all.
for z = 1:num files;
subplot(1,2,2);
hold on
grid on;
for i = 1:5
plot(z) = plot(StartA(:,i),AMA_1(:,i),color)
end
end
legend(plot(1),plot(2), etc… subplot, legend, figure, plotting MATLAB Answers — New Questions