0

This is my first attempt to use matplotlib and failing... I have lists of data as:

years = [1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014]

temps = [14.11, 7.54, 5.22, 3.81, 2.9, 2.7, 2.4, 1.82, 1.66, 1.52, 1.34, 1.19, 1.12, 1.17, 1.04, 0.87, 0.87, 0.89, 0.76, 0.75, 0.73, 0.72, 0.69, 0.64, 0.62, 0.62, 0.6, 0.64, 0.53, 0.49]

years should be the x-axis and the temps should be the y-axis. Can't figure it how.

`plt.hist([temps, years], bins=10)
plt.title('Temp_histogram')
plt.xlabel('year')
plt.ylabel('temp')
plt.grid(True)
plt.show()`

enter image description here

2
  • Isn't it what you've done already ? Given your histogram plot I d'ont understand your question ... Commented Oct 4, 2016 at 18:21
  • No, We should only see the values of temp in the histogram fluctuating, not both of them in the histogram. At the end, I would like to see the temperature data histogram over the years Commented Oct 4, 2016 at 18:22

1 Answer 1

1

Are you sure that you want a histogram and not a simple bar chart? Something like this:

plt.bar(years,temps, 1, color='r')
plt.title('Temp_histogram')
plt.xlabel('year')
plt.ylabel('temp')
plt.grid(True)
plt.show()

enter image description here

If you really want a histogram then think about (or tell us) by what quantity (a quantitiy is a physical entity, like "year" or "temp" in this case) you want to group the data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.