qwertylpc
qwertylpc

Reputation: 2116

Change Axis for Historgram with PyPlot

Reading the documentation here, I need help limiting the histogram from 53 to 75. First, I have the code,

plt.hist(d, bins=range(min(d), max(d) + binwidth, binwidth), label='diff', align='mid', normed=True, alpha = .8, color=colors[2])
plt.hist(s, bins=range(min(s)-1, max(s) + binwidth, binwidth), label='same', align='mid', normed=True, alpha = .5, color=colors[0])

which is fine in plotting this histogram enter image description here.

However, I want to zoom in on the area above 53. (Explicitly 53 to 75). When I try this,

min_ = 53
plt.hist(d, bins=range(min_,75), label='diff', align='mid', normed=True, alpha = .8, color=colors[2])
plt.hist(s, bins=range(min_,75), label='same', align='mid', normed=True, alpha = .5, color=colors[0])

I instead of zooming in on the specified area, I zoom in and renorm the area. The issue is tat I need to have the original normed area because the samples are very different sizes. However when zooming in to the tail, I don't want to renorm the data.

Upvotes: 1

Views: 43

Answers (1)

Jason
Jason

Reputation: 2743

Use the plt.axis() function instead. For example:

plt.axis([53, 75, 0, .01])

Upvotes: 1

Related Questions