Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Need Help In Matlplotlib Plotting

I am given a dataset and I am supposed to plot: How much does each player get paid per game on average?

I converted the dataset into a NumPy array:

Salary = np.array([KobeBryant_Salary, JoeJohnson_Salary, LeBronJames_Salary, 
                   CarmeloAnthony_Salary, DwightHoward_Salary, ChrisBosh_Salary, 
                   ChrisPaul_Salary, KevinDurant_Salary, DerrickRose_Salary, 
                   DwayneWade_Salary])
Games = np.array([KobeBryant_G, JoeJohnson_G,LeBronJames_G, CarmeloAnthony_G, 
                  DwightHoward_G, ChrisBosh_G, ChrisPaul_G, KevinDurant_G, 
                  DerrickRose_G, DwayneWade_G])

After that, I wrote a for loop, and iterated through this array:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

for i in range(0,10):
    plt.plot(Salary[i]/Games[i])

Since one of the players had played 0 games it is showing the ZeroDivisionError in my plot.
I wanted to know is this the right approach? Also if it is correct can I please how can I format the y axis so that the lower values are visible better (I tried playing with yticks but it didn’t help much).

enter image description here

>Solution :

I ran your code. It does not throw any ZeroDivisionError, rather throws a warning. For improving the visibility of the results, you should use plt.yscale("log") so that lower values will be visible.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading