I have the following pandas dataframe having thousands of rows.
I want to plot a 2D histogram based on "mains:active_power" and "mains:reactive_power". I used matplotlib library for plotting the 2D histogram in Python:
import matplotlib.pyplot as plt
fig = plt.subplots(figsize =(10, 7))
plt.hist2d(df["mains:active_power"], df["mains:reactive_power"])
plt.title("Simple 2D Histogram")
plt.show()
It plots successfully, but I want to customize the bin values for both x_bin and y_bin. I used following command for it:
plt.hist2d(df["mains:active_power"], df["mains:reactive_power"], bins =[x_bins, y_bins]).
x_bins, y_bins are the NumPy array containing the value of the bin. Also, the size of x_bins, y_bins equals the length of dataframe (df)
Whenever I run this, I got an error:
ValueError: bins[0]
must be monotonically increasing, when an array
How to troubleshoot this?
Thanks :)