Trouble setting plot axis limits with matplotlib / python -


i have code:

def print_fractures(fractures):     # generate ends line segments     xpairs = []     ypairs = []     plt.subplot(132)      in range(len(fractures)):         xends = [fractures[i][1][0], fractures[i][2][0]]         yends = [fractures[i][1][1], fractures[i][2][1]]         xpairs.append(xends)         ypairs.append(yends)     xends,yends in zip(xpairs,ypairs):         plt.plot(xends, yends, 'b-', alpha=0.4)         plt.plot()     plt.xlabel("x coordinates (m)")     plt.ylabel("y coordinates (m)")     plt.ylim((0,400))   def histogram(spacings):     plt.subplot(131)     plt.hist(np.vstack(spacings), bins = range(0,60,3), normed=true)     plt.xlabel('spacing (m)')     plt.ylabel('frequency (count)')     #plt.title("fracture spacing histogram")   def plotci(sample, cihigh, cilow, avgints):     plt.subplot(133)         plt.plot(sample,cihigh)     plt.plot(sample,avgints)     plt.plot(sample,cilow)     plt.legend(['mean + 95% ci', 'mean', 'mean - 95% ci'])     plt.title("intersections vs number of wells")     plt.xlabel("# of wells")     plt.ylabel("# of intersections " + str(bedt) + "m bed thickness")  def makeplots(spacings,fractures):      histogram(spacings)     print_fractures(fractures)     plt.axis('equal')     plotci(sample, cihigh, cilow, avgints)     plt.show() makeplots(spacings,fractures) 

the code produces following plot: enter image description here

as can see, in center plot, plot not centered... set x , y axes (0,400) having troubles.

so far have tried:

plt.axis((0,400,0,400)) 

and:

plt.ylim((0,400)) plt.xlim((0,400)) 

neither option worked me.

in example, not shown how / when functions called. there possible side effects concerning plt.ion()/plt.ioff() , focus of actual plot @ time of executing xlim()/ylim() commands.

to have full control (especially, when having more 1 plot), better have explicit figure , plot handles, e.g:

fg = plt.figure(1) fg.clf()  # clear figure, in case script not executed first time  ax1 = fg.add_subplot(2,1,1) ax1.plot([1,2,3,4], [10,2,5,0]) ax1.set_ylim((0,5)) # limit yrange  ax2 = fg.add_subplot(2,1,2)     ...  fg.canvas.draw()  # figure drawn @ point  plt.show()  # enter gui event loop, needed in non-interactive interpreters 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -