Why are matplotlib histogram edges only showing on the top of the bars?

Viewed 385

Using Spyder 4 and Python 3.7, I run the below code to get these histogram subplots.

The left histogram (first described in the code) only has black borders along the top of the bars, while the right histogram has black borders around each individual bar. How do I get them both to be like the right one?

#%% Get Data

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator

data = pd.read_csv("Sup20200305_002 analysis20200325.csv")

#%% Make Figure

fig = plt.figure(figsize=[10,4])

ax1 = fig.add_subplot(1,2,1)
ax1.hist(np.clip(data['Area_um2'], 0, 150), bins=np.arange(2,150,5), histtype='stepfilled', color='purple', edgecolor='black')
ax1.set_xlabel('Flake Area / $\mu m^2$')
ax1.set_ylabel('Number Counted')
ax1.axis([0,150,0,160])
ax1.set_xticks(np.arange(0,151,15))
ax1.xaxis.set_minor_locator(MultipleLocator(5))

ax2 = fig.add_subplot(1,2,2)
ax2.set_xlabel('Flake Diameter / $\mu m$')
ax2.hist(np.clip(data['Diameter_um'], 0, 14), bins=np.arange(1,14,1), edgecolor='black')
ax2.set_ylabel('Number Counted')
ax2.axis([0,14,0,170])
ax2.set_xticks(np.arange(0,15,2))
ax2.xaxis.set_minor_locator(MultipleLocator(1))```
0 Answers
Related