python - Multiple Broken Axis On A Histogram in Matplotlib -
So I have some data that I want to plot through the frequency density (unequal square width) histogram, and some Search through online, I made it so that I could get permission to do this.
As you can see, this data is spread over thousands of x axis and on the y axis (density) small data ( & Lt; 1) leads to huge data (> 100). To solve this I need to break both the axes. I have found so far to help, which is the hardest to use, will you be able to help? Thanks, AJ.
You can use the plot only once. Setting xtick labels to represent uninterrupted values
with logarithmic y scale < / P>
Import numpy NP as import matplotlib.pyplot as plt plt.xkcd () fig, ax = plt.subplots () freqs = np.array ([3221, 1890, 866] , 52, 9, 434, 494, 382, 92, 32, 7, 7]) Freqs = np.log10 (freqs) bins = np.array ([0, 5, 10, 15, 20, 30, 50, 100, 200, 500, 1000, 1500]) width = 0.35 Ind = NP. Lane (Frequance)) rects1 = ax.bar (Ind, Freq, width) plt.xlabel ('cost in pounds') plt.ylabel ('frequency density') tick_labels = ['{0} - {1}'. Format (* bin) in zip (bins [: - 1], bins [1:]) ax.set_xticks (ind + width) ax.set_xticklabels (tick_labels) fig.autofmt_xdate () plt.show ()
< / Pre>
Comments
Post a Comment