Skip to content Skip to sidebar Skip to footer

When I Plot 2 Columns One Over The Other, A Different Graph Is Plotted

I have 2 columns from 2 np.arrays of the same size. When I plot the only the one I get this result: plt.figure(figsize=(70,10)) for i,h in enumerate(clean_head): plt.subp

Solution 1:

in the second set of plots the blue histogram is for the "non-fire"-case and the orange one is for the "fire"-case. If you would plot a third histogram, it would be green. In general you can change the color of a given histogram using the parameter color.

The reason why your histograms change is that your arrays have different value ranges. You can fix this by explicitly giving bins the the function:

import matplotlib.pyplot as plt
import numpy as np

a = np.random.rand(100)
b = np.random.rand(100)*2

bins = np.linspace(min(np.min(a), np.min(b)), max(np.max(a), np.max(b)), 10)

plt.figure(figsize=(7,5))
plt.hist(a,alpha=.3, bins=bins)
#plt.hist(b,alpha=.3, bins=bins) #toggle this to see the effect

Also note that histogram function returns the list of bins that it uses.

Hope that helps.

Post a Comment for "When I Plot 2 Columns One Over The Other, A Different Graph Is Plotted"