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 ->

and 1 didn't ->enter image description here

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:

  1. is there way fix , reflect data is?
  2. is better give rank values different labels separate them more 1 example - 1,2,3,4 or lose precision of data , useful info?
  3. 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)) 

enter image description here


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -