1

I am a bit confused with my inability to replace the xticks in a bar plot.

For a reproducible example here are some data:

images_per_patient_quantiles.to_json()
'{"quantile":{"0":0.0,"1":0.05,"2":0.1,"3":0.15,"4":0.2,"5":0.25,"6":0.3,"7":0.35,"8":0.4,"9":0.45,"10":0.5,"11":0.55,"12":0.6,"13":0.65,"14":0.7,"15":0.75,"16":0.8,"17":0.85,"18":0.9,"19":0.95,"20":1.0},"number_of_images_per_patient":{"0":20.0,"1":28.0,"2":28.0,"3":30.0,"4":31.0,"5":32.0,"6":32.0,"7":32.0,"8":32.0,"9":33.0,"10":34.0,"11":35.0,"12":36.0,"13":36.0,"14":37.0,"15":40.0,"16":40.0,"17":42.0,"18":52.0,"19":71.0,"20":548.0}}'

If i plot the data the xtick labels are confused as below:

enter image description here

On the other hand if I try to replace them I get this oddity below which I can not explain:

sns.barplot(x = 'quantile', y = 'number_of_images_per_patient', data = images_per_patient_quantiles, color = 'crimson')
plt.xticks(ticks = np.arange(0,1.05, 0.05), labels = np.arange(0,1.05, 0.05))

enter image description here

From the documentation I understand that I can also pass arguments that would format the ticks and possibly this would also improve the readability of the chart:

enter image description here

How this can be done?

halfer
  • 19,824
  • 17
  • 99
  • 186
user8270077
  • 4,621
  • 17
  • 75
  • 140
  • 1
    Possible duplicate of [Matplotlib: Specify format of floats for tick lables](https://stackoverflow.com/questions/29188757/matplotlib-specify-format-of-floats-for-tick-lables) – Don Kirkby Oct 26 '19 at 04:45
  • There is no need to add `Your advice will be appreciated` to the footer of all of your questions. You've probably had ~100 removed by now. – halfer Oct 28 '19 at 00:17
  • Remember that the editors that try to keep this place tidy are volunteers. We may be foolish for taking on the task, but we believe in this community, for all its many faults. We would rather not have to clean up after users who add redundant and conversational material wilfully. – halfer Oct 28 '19 at 00:17

0 Answers0