How to join two lines in the same scale of the graph?

Asked

Viewed 119 times

0

Hello!

I have the following code:

def createGraph():
    plt.title("Evolution of COVID-19")
    plt.xlabel("Days")
    plt.ylabel("Infected People")

    countries = ['China', 'Italy']
    days = [1,...,63] #Array from 1 to 63

    for country in countries:
        #createArray(country, type) returns an array with 63 values
        plt.plot(days, createArray('China', "infected"), color = 'red')

    plt.legend()
    plt.show()

The graph that appears is as follows:

Gráfico resultante

As you can see, the Y axis breaks in half and starts again from 0... Can anyone help me to put the two lines starting from 0 (bottom left corner)?

Thank you!

1 answer

0

Mine has worked out:

import matplotlib.pyplot as plt

def createGraph():
    plt.title("Evolution of COVID-19")
    plt.xlabel("Days")
    plt.ylabel("Infected People")

    countries = ['China', 'Italy']
    days = [1, 2, 3] #Array from 1 to 63

    infect = {
        'China': [10, 20, 30],
        'Italy': [11, 80, 170]
            }

    for country in countries:
        #createArray(country, type) returns an array with 63 values
        plt.plot(days, infect[country])

    plt.legend()
    plt.show()

createGraph()

I wish you could send the whole code so I could see right, I had to adapt a lot of things to work. The way I did, it didn’t stick.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.