4

I'm wanting to remove the vertical bar outlines from my histogram plot, but preserving the "etching" of the histogram, if that makes since.

import matplotlib.pyplot as plt
import numpy as np  

bins = 35

fig = plt.figure(figsize=(7,6))
ax = fig.add_subplot(111)

ax.hist(subVel_Hydro1, bins=bins, facecolor='none', 
        edgecolor='black', label = 'Pecuiliar Vel')
ax.set_xlabel('$v_{_{B|A}} $ [$km\ s^{-1}$]', fontsize = 16)
ax.set_ylabel(r'$P\ (r_{_{B|A}} )$', fontsize = 16)
ax.legend(frameon=False)

Giving

enter image description here

Is this doable in matplotlibs histogram functionality? I hope I provided enough clarity.

iron2man
  • 1,787
  • 5
  • 27
  • 39
  • Title says horizontal, body says vertical. You might want to correct one of them. – Lafexlos Sep 07 '16 at 14:24
  • @Lafexlos My apologies, it's been a long morning. – iron2man Sep 07 '16 at 14:25
  • are you set on having the same color for both the histogram and the background? creating the 'silhouette' effect would be easy if you can fill the bars the same color as the lines. – benten Sep 07 '16 at 14:28

1 Answers1

7

In pyplot.hist() you could set the value of histtype = 'step'. Example code:

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

x = np.random.normal(0,1,size=1000)

fig = plt.figure()
ax = fig.add_subplot(111)

ax.hist(x, bins=50, histtype = 'step', fill = None)



plt.show()

Sample output:

enter image description here

TuanDT
  • 1,627
  • 12
  • 26