dimanche 10 juillet 2016

Python mathplotlib - overlapping texts in xticks and adding percentage symbol in yticks

The following is my Python code for generating a bar chart:

import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt

objects = ('Increasing operational efficiency',
       'Informing strategic direction',
       'Better customer service',
       'Identifying and developing new products',
       'Enhanced customer experience',
       'Identifying new markets',
       'Faster go to market',
       'Complying with regulations',
       'Other')
y_pos = np.arange(len(objects))
performance = [51, 36, 27, 24, 20, 11, 8, 6, 3]

plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)

plt.show()

In the output the xticks are getting overlapped, is there any way to overcome it. My second doubt is in the yticks the values are coming from 0 to 60 with a interval of 10, is there any way to add a '%' symbol along with the number like 0%, 10%, ..., 60% rather than 0, 10, ..., 60.

Thank you for the help, I am new to mathplotlib

Aucun commentaire:

Enregistrer un commentaire