##// END OF EJS Templates
Fix dynamic 'xstep' for all Plots
George Yong -
r1204:d22cda2f4921
parent child
Show More
@@ -615,20 +615,41 class Plot(Operation):
615
615
616 ymin = self.ymin if self.ymin else numpy.nanmin(self.y)
616 ymin = self.ymin if self.ymin else numpy.nanmin(self.y)
617 ymax = self.ymax if self.ymax else numpy.nanmax(self.y)
617 ymax = self.ymax if self.ymax else numpy.nanmax(self.y)
618 Y = numpy.array([1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000])
618 #Y = numpy.array([1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000])
619
619 #i = 1 if numpy.where(
620 #i = 1 if numpy.where(
620 # abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0]
621 # abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0]
621 #ystep = Y[i] / 10.
622 #ystep = Y[i] / 10.
622 dig = int(numpy.log10(ymax))
623 dig = int(numpy.log10(ymax))
624 if dig == 0:
625 digD = len(str(ymax)) - 2
626 ydec = ymax*(10**digD)
627
628 dig = int(numpy.log10(ydec))
629 ystep = ((ydec + (10**(dig)))//10**(dig))*(10**(dig))
630 ystep = ystep/5
631 ystep = ystep/(10**digD)
632
633 else:
623 ystep = ((ymax + (10**(dig)))//10**(dig))*(10**(dig))
634 ystep = ((ymax + (10**(dig)))//10**(dig))*(10**(dig))
624 ystep = ystep//10
635 ystep = ystep/5
636
625 if self.xaxis is not 'time':
637 if self.xaxis is not 'time':
626 X = numpy.array([0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100,
627 200, 500, 1000, 2000, 5000, 10000, 20000, 50000])/2.
628
638
629 i = 1 if numpy.where(
639 dig = int(numpy.log10(xmax))
630 abs(xmax-xmin) <= X)[0][0] < 0 else numpy.where(abs(xmax-xmin) <= X)[0][0]
640
631 xstep = X[i] / 5.
641 if dig <= 0:
642 digD = len(str(xmax)) - 2
643 xdec = xmax*(10**digD)
644
645 dig = int(numpy.log10(xdec))
646 xstep = ((xdec + (10**(dig)))//10**(dig))*(10**(dig))
647 xstep = xstep*0.5
648 xstep = xstep/(10**digD)
649
650 else:
651 xstep = ((xmax + (10**(dig)))//10**(dig))*(10**(dig))
652 xstep = xstep/5
632
653
633 for n, ax in enumerate(self.axes):
654 for n, ax in enumerate(self.axes):
634 if ax.firsttime:
655 if ax.firsttime:
General Comments 0
You need to be logged in to leave comments. Login now