[Python] matplotlib.pyplot scatter s parameter meaning

Discussão em 'Python' iniciado por Stack, Junho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I am follwoing a Datacamp Course on Data Science and I have the following script:

    # Import numpy as np
    import numpy as np

    # Store pop as a numpy array: np_pop
    np_pop = np.array(pop)

    # Double np_pop
    np_pop*=2

    # Update: set s argument to np_pop
    plt.scatter(gdp_cap, life_exp, s = np_pop)

    # Previous customizations
    plt.xscale('log')
    plt.xlabel('GDP per Capita [in USD]')
    plt.ylabel('Life Expectancy [in years]')
    plt.title('World Development in 2007')
    plt.xticks([1000, 10000, 100000],['1k', '10k', '100k'])

    # Display the plot
    plt.show()


    It displays the following Plot

    My Question is what does it mean for the s parameter in scatter to be an array. I understand when it's an int it's the size of the points. However, in the array case, does it map every entry in the array to the size of that specific data Point.

    Continue reading...

Compartilhe esta Página