1

I m a student and I m in a huge trouble, I am trying to visualize a plot of 2 variables x and y the number of data points in x and y are like 100 thousand or similar and the data in is float and almost with 3 decimal placesfoe eg 0.002 or 12.003.

When i try to plot it using plt.hist i get weird lines in my plot when i give it different bins sometimes some bins work perfect. I have attached the image of plot and code below pls help. Like this one is perfect One line appears here

More lines appear here

and so on.. it just happens when i increase binning number in my code like bins =[46,46] and bins =[47,47] and so on and then there will be a specific bin number where it would appear okayish and perfect i dont know why this is happening

plt.hist2d(df3.Yaxis, df3.YError,bins =[45,45])
plt.colorbar()
plt.title("EMF OFF X- axis")
plt.xlabel("mm")
plt.show()

Pls help me explain this

I tried many other libraries in python all have the same problem while plotting. I tried to do the same stuff in matlab and it works flawlessly but pls make me understand why python is like this

Ankur Giri
  • 11
  • 2
  • you can try defining a third argument `range`, which edges is specified for the bins along each dimension, and is defined as an array of 2 element arrays `[[xmin, xmax], [ymin, ymax]]` you should go testing using the length of x and y as minimum greater than 0 and maximum less than length or some value of `[x, y]` – user11717481 Nov 17 '22 at 02:48
  • OK i tried but it just keeps making it worse – Ankur Giri Nov 17 '22 at 11:38

0 Answers0