I am trying to make multiple plots within a for loop based on some condition and after the for loop terminates, I want to save the plot files. I can do this with MATLAB, but not sure how to do this in python. Here is a sample code in MATLAB:
A = [some 2d matrix]
B = [some 2d matrix]
[row, col] = size(A)
for ii = 1:row
x = A(ii,:)
y = B(ii,:)
if (some condition)
figure(1)
plot(x,y)
hold on
elseif (some condition)
figure(2)
plot(x,y)
hold on
elseif (some condition)
figure(3)
plot(x,y)
hold on
else
figure(4)
plot(x,y)
hold on
end
end
figure(1)
xlabel(...)
ylabel(...)
legend(...)
saveas()
figure(2)
xlabel(...)
ylabel(...)
legend(...)
saveas()
figure(3)
xlabel(...)
ylabel(...)
legend(...)
saveas()
figure(4)
xlabel(...)
ylabel(...)
legend(...)
saveas()
I want to do this in python, please help me through this.
Thank you.
I tried some matplotlib pyplot, but it does not seem to fulfill my requirements.