Make 1 figure with 3 graphics

2

I have 3 functions like the following that allows to obtain each one a graph and I intend a function in which it uses the 3 graphs of the other functions to join in a single figure.

def funcao1(grafico):
    ...
    pylab.plot(range(len(x)), y)
    pylab.xticks(z,sorted(set(x)))
    pylab.title("crimes")
    pylab.xlabel("Anos")
    pylab.ylabel("# Crimes")
    pylab.show()

def funcao2(grafico):
    ...
    pylab.plot(range(len(y)), x)
    pylab.xticks(b,sorted(set(y)))
    pylab.title("nomes")
    pylab.xlabel("Anos")
    pylab.ylabel("# Crimes")
    pylab.show()

def funcao3(grafico):
    ...
    pylab.plot(range(len(a)), e)
    pylab.xticks(p,sorted(set(a)))
    pylab.title("idades")
    pylab.xlabel("Anos")
    pylab.ylabel("# Crimes")
    pylab.show()

def quatro_figuras(grafico):

      #Aqui obter uma figura com os 3 graficos
    
asked by anonymous 23.05.2016 / 19:35

1 answer

2

I think you should use the subplot command, if I'm not mistaken the code should look like this:

y = [1,2,3]
x = [5,6,7]

def funcao1(): 
    pylab.subplot(221)
    pylab.title("crimes")
    pylab.xlabel("Anos")
    pylab.ylabel("# Crimes")
    pylab.plot(range(len(x)), y)

def funcao2():
    pylab.subplot(222)
    pylab.title("nomes")
    pylab.xlabel("Anos")
    pylab.ylabel("# Crimes")
    pylab.plot(range(len(x)), y)

def funcao3():
    pylab.subplot(223)
    pylab.title("idades")
    pylab.xlabel("Anos")
    pylab.ylabel("# Crimes")
    pylab.plot(range(len(x)), y)

def quatro_figuras():
    pylab.show()

funcao1()
funcao2()
funcao3()
quatro_figuras()

Since the 1st digit corresponds to the number of graph lines, the 2nd the number of columns and the 3rd corresponds to the number of each graph. An example can be seen here .

Change the example according to your work.

    
24.05.2016 / 11:27