I am trying to plot median salaries by age with matplotlib. The code is as follows:
from matplotlib import pyplot as plt
dev_x = [x for x in range(25, 36)]
dev_y = [38496, 42000, 46752, 49320, 53200, 56000, 62316, 64928, 67317, 68748, 73752]
plt.plot(dev_x, dev_y)
plt.title("Median salary (USD) by age")
plt.xlabel("Age")
plt.ylabel("Median salary (USD)")
plt.show()
When running this in pycharm as a file, it works as expected. However, the first time around, I was using the python console, the title, x and y label were not showing up. What would end up happening is when I would enter plt.plot(dev_x, dev_y), the plot would show up. After that when I would add the title and axis labels, it would show an empty plot witch the individual elements. Furthermore, in the console plt.show() does nothing. Can someone please explain what I am doing wrong?