0

I have 2 lists:

    X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] 
    Y = [0.5717, 0.699, 0.7243, 0.5939, 0.5383, 0.5093, 0.7001, 0.589, 0.6486, 0.7152, 0.6805, 0.5688, 0.6133, 0.6041, 0.5676].
    plt.xlabel('X')
    plt.ylabel('Y'))
    plt.title("Histogram")
    xbins = [x for x in range(len(Xaxis))]
    numBins = len(Xaxis)
    plt.hist(Xaxis,xbins ,color='green',alpha=0.6)
    plt.show()
    plt.close()

When I am doing like this i am not getting correctly.so if i want to plot an histogram using this data. How can I do that using python programming?

sinhayash
  • 2,693
  • 4
  • 19
  • 51
  • @sinhayash I have checked various examples and tried but that doent solve my problem. –  Jul 02 '15 at 07:58

1 Answers1

2

I'm not sure if I understand your question, but I'll give it a shot:

import matplotlib.pyplot as plt
X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] 
Y = [0.5717, 0.699, 0.7243, 0.5939, 0.5383, 0.5093, 0.7001, 0.589, 0.6486, 0.7152, 0.6805, 0.5688, 0.6133, 0.6041, 0.5676]
plt.bar(X, Y, color='green', alpha=0.6, align='center')
plt.xlabel('X')
plt.ylabel('Y')
plt.title("Histogram")
plt.show()

Is that the plot you are looking for? If not, please provide more details. enter image description here

Daniel Lenz
  • 3,334
  • 17
  • 36
  • I did the the bar graph and it is working fine for me. My doubt is can i be able to draw a histogram using 2 lists? –  Jul 02 '15 at 09:06
  • I'm afraid that for the data you have provided, it would make no sense to create a histogram, be it one- or two-dimensional. – Daniel Lenz Jul 02 '15 at 09:36
  • Ok Thank you. After plotting a graph if i move the mouse over the graph i want to display the values.How can i do that? –  Jul 02 '15 at 10:14