Making a .gif from a for loop of plotted images

36 views (last 30 days)
I have a few questions but first here is my code:
[file_list, path_n]=uigetfile('.csv','Grab the files you want to process','Multiselect','on')
if iscell(file_list) == 0
file_list = (file_list);
end
N = length(file_list);
for i = 1:N
filename = file_list{i};
data_in = xlsread([path_n filename])
hold on
depth = data_in(:,1);
Axial_stress = data_in(:,2);
plot(depth, Axial_stress)
xlabel('cm')
axis auto
ylabel('kbar')
legend(filename)
drawnow
end
The overall goal is to make a .gif (if possible, otherwise the drawnow function will work) of the different graphs that are coming from this data but I have a few questions
  1. How do i choose the colors for the lines? Any sort of line color choice function didnt seem to work for me, maybe I am missing something simple
  2. Is it possible to diplay the currently plotting graph in the legend then once all the graphs are plotted, have a "total" graph that has all the lines in the legend?
  3. How can I extract only the last 8 characters of the filename to use for the legend?
  4. How can i have the x axis min be set, but let the x axis max and y axis min and max be floating and not dependant on the first file in my for loop?

Answers (2)

Image Analyst
Image Analyst on 16 Apr 2021
See if you can find something similar in a search of the forum:
Or the blogs and file exchange:

Image Analyst
Image Analyst on 16 Apr 2021
To make a movie of the plots, see my attached demo.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!