python - Need to fix x-axis and y-axis for a graph so that I can clearly see the representation -


i have image being produced output in python(spyder). numbers on y-axis cluttered, , impossible read them. how can make graph such every number on y-axis clear read. want change length of x-axis, user can idea of value each bar corresponds on x-axis. hard read @ point.

so, yes want change both x-axis , y-axis in own ways mentioned above. please me this. using import matplotlib.pyplot plt, please don't change that. please follow link below image of graph getting.

http://i57.tinypic.com/6g8obb.png

here code:

temparray = mynumpread[:,1] barh = plt.subplot(111) width = 0.8 barh.barh(range(len(states)), temparray) barh.set_ylim(-width,len(states)+width) barh.set_yticks(np.arange(len(states)) + width/2) barh.set_yticklabels(states, rotation=0) plt.title('population state') plt.xlabel('population') plt.ylabel('state ticker') plt.grid(true) plt.show() 

thank help.

your question difficult answer because code not reproducible without variables , cannot see picture in link provided.

however, increasing width of figure may asking for. can done so:

import numpy np import matplotlib.pyplot plt  x = np.linspace(0, 1) y = x**2  fig = plt.figure(figsize=(10, 3)) # 10 here width, 3 height ax = fig.add_subplot(111) ax.plot(x, y) plt.show(fig) 

let me know if helps. if further please post code can reproduce problem without requiring variables. ie. write code can run stand alone.

edit after seeing picture

does changing code following fix issue?

temparray = mynumpread[:,1] fig = plt.figure(figsize=(5, 15)) # change these numbers here suit want ax = fig.add_subplot(111) width = 0.8 ax.barh(range(len(states)), temparray) ax.set_ylim(-width,len(states)+width) ax.set_yticks(np.arange(len(states)) + width/2) ax.set_yticklabels(states, rotation=0) ax.set_title('population state') ax.set_xlabel('population') ax.set_ylabel('state ticker') ax.grid(true) plt.show(fig) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -