2

my output is kinda messy. I want the states on the x-axis to be visible

performance0 = denied_states['STATE'].value_counts().sort_index()
performance1 = certified_states['STATE'].value_counts().sort_index() 
performance2 = cw_states['STATE'].value_counts().sort_index()
performance3 = w_states['STATE'].value_counts().sort_index()
plt.plot( performance0, label = 'Denied')
plt.plot( performance1, label = 'Certified')
plt.plot( performance2, label = 'Certified-Withdrawn')
plt.plot( performance3, label = 'Withdrawn')
plt.xticks(rotation=90)
plt.xlabel('States')

plt.ylabel('Applications')
plt.title('No. of Applicants status of H1B Visa based on states')
plt.legend()
plt.show()

Output:

output graph

AustinWBryan
  • 3,249
  • 3
  • 24
  • 42

1 Answers1

0
  1. Syntax for setting the xticks is:

    xticks(locs, [labels], **kwargs)  # Set locations and label
    

    **kwargs may contain Text properties, among them the fontproperties keyword to which you may assign a FontProperties object.

    So you could try something like:

    fp = matplotlib.font_manager.FontProperties(family="sans-serif", size=8)  # play around with the formatting
    plt.xticks(rotation=90, fontproperties=fp)
    
  2. Another possibility would be to increase the size of the whole plot which is described in: How do you change the size of figures drawn with matplotlib?

ascripter
  • 5,665
  • 12
  • 45
  • 68