Python with matplotlib – drawing multiple figures in parallel

Question:

I have functions that contribute to small parts of a figure generation. I’m trying to use these functions to generate multiple figures? So something like this:

  1. work with Figure 1
  2. do something else
  3. work with Figure 2
  4. do something else
  5. work with Figure 1
  6. do something else
  7. work with Figure 2

If anyone could help, that’d be great!

Asked By: aspade

||

Answers:

There are several ways to do this, and the simplest is to use the figure numbers. The code below makes two figures, #0 and #1, each with two lines. #0 has the points 1,2,3,4,5,6, and #2 has the points 10,20,30,40,50,60.

from pylab import *

figure(0)
plot([1,2,3])

figure(1)
plot([10, 20, 30])

figure(0)
plot([4, 5, 6])

figure(1)
plot([40, 50, 60])

show()
Answered By: tom10

For a more general answer to this question and to questions you may soon have, I would recommend the official tutorial.

Answered By: Eric O Lebigot

The best way to show multiple figures is use matplotlib or pylab. (for windows)
with matplotlib you can prepare the figures and then when you finish the process with them you can show with the comand “matplotlib.show()” and all figures should be shown.

(on linux) you donĀ“t have problems adding changes to figures because the interactive mode is enable (on windows the interactive mode don’t work OK).

Answered By: Steve Rod
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.