Any way to create histogram with matplotlib.pyplot without plotting the histogram?

前端 未结 4 2169

I am using matplotlib.pyplot to create histograms. I\'m not actually interested in the plots of these histograms, but interested in the frequencies and bins (I know I can write

4条回答
  •  不知归路
    2021-02-20 06:44

    No.

    But you can bypass the pyplot:

    import matplotlib.pyplot
    
    fig = matplotlib.figure.Figure()
    ax = matplotlib.axes.Axes(fig, (0,0,0,0))
    numeric_results = ax.hist(data)
    del ax, fig
    

    It won't impact active axes and figures, so it would be ok to use it even in the middle of plotting something else.

    This is because any usage of plt.draw_something() will put the plot in current axis - which is a global variable.

提交回复
热议问题