Troble view plots

Screen Link: <

My Code: <!recent_grads.plot(x=“Major”, y= “Median”)

What I expected to happen:
i was expected to see plot

What actually happened:
only code runs without error but unable to see plot

Replace this line with the output/error

If you could appropriately format the code in your post, that would help.

Also, couple of things

  1. Did you use after the plotting command?

  2. Do you have the statement %matplotlib inline added since it allows for plots to be displayed in the Notebook?

thanks, i did not put %matplotlib inline . what is the purpose of it? when to include and when not to include. Because I tried to run same code without %matplotlib inline in my Jupyter notebook and it worked.
Thank you in advance.

It’s to display any plots you might have in the Notebook. That is, if you run a particular Cell which has some plotting code that uses or relies on matplotlib, the inclusion of %matplotlib inline will allow that plot to be displayed as an output of that Cell when you run it.

If you wish to display your plots (using matplotlib) when working with Jupyter Notebooks, this is pretty much a necessity. You should ideally just make it a habit to add this as a statement right after you import matplotlib.

Hello, when I did the scatter plot for Full-time vs Median, I got the error message KeyError: ‘Full-time’
Why is this?
My code:

ax3 = recent_grads.plot(x='Full-time', y='Median', kind='scatter')
ax3.set_title('Full-time vs Median')

In your code you have used dash ("-") instead of underscore “_”. correct code should be as bellow:

ax3 = recent_grads.plot(x=‘Full_time’, y=‘Median’, kind=‘scatter’)
ax3.set_title(‘Median vs. Full_time’)

1 Like