python - Plotting high precision data as axis ticks or transforming it to different values? -
i trying plot data histogram in matplotlib using high precision values x-axis ticks. data between 0 , 0.4, values close like:
0.05678, 0.05879, 0.125678, 0.129067
i used np.around()
in order make values (and made them should 0 0.4) less didn't work quite right of data. here example of 1 worked right ->
you can see there points after 0.4 not right. here code used in jupyter notebook
:
plt.hist(x=[advb_ratios,adj_ratios,verb_ratios],color = ['r','y','b'], bins =10, label = ['adverbs','adjectives', 'verbs']) plt.xticks(np.around(ranks,1)) plt.xlabel('argument rank') plt.ylabel('frequency') plt.legend() plt.show()
it same both histograms different x
plotting, x
values used between 0 , 1
.
so questions are:
- is there way fix , reflect data is?
- is better give
rank
values different labels separate them more 1 example - 1,2,3,4 or lose precision of data , useful info? - what general approach in such situations? different graphic help? what?
i don't understand problem, fact data between 0 , 0.4 should not influence way displayed. don't see why need else call plt.hist()
.
in addition, can pass array bins
argument indicate bins want, force size of bins same
# fake data x1 = np.random.normal(loc=0, scale=0.1, size=(1000,)) x2 = np.random.normal(loc=0.2, scale=0.1, size=(1000,)) x3 = np.random.normal(loc=0.4, scale=0.1, size=(1000,)) plt.hist([x1,x2,x3], bins=np.linspace(0,0.4,10))
Comments
Post a Comment