def ticks(self): ''' Get ticks for quarterLength. If `remap` is `True` (the default), the `remapQuarterLength()` method will be used to scale displayed quarter lengths by log base 2. Note that mix and max do nothing, but must be included in order to set the tick style. >>> s = stream.Stream() >>> for t in ['32nd', '16th', 'eighth', 'quarter', 'half']: ... n = note.Note() ... n.duration.type = t ... s.append(n) >>> plotS = graph.plot.PlotStream(s) >>> ax = graph.axis.QuarterLengthAxis(plotS) >>> ax.ticks() [(-3.0, '0.1...'), (-2.0, '0.25'), (-1.0, '0.5'), (0.0, '1.0'), (1.0, '2.0')] >>> ax.useLogScale = False >>> ax.ticks() [(0.125, '0.1...'), (0.25, '0.25'), (0.5, '0.5'), (1.0, '1.0'), (2.0, '2.0')] >>> ax.useDurationNames = True >>> ax.ticks() [(0.125, '32nd'), (0.25, '16th'), (0.5, 'Eighth'), (1.0, 'Quarter'), (2.0, 'Half')] The second entry is 0.125 but gets rounded differently in python 2 (1.3) and python 3 (1.2) >>> nGrace = note.Note() >>> nGrace.getGrace(inPlace=True) >>> s.append(nGrace) >>> plotS = graph.plot.PlotStream(s) >>> ax = graph.axis.QuarterLengthAxis(plotS) >>> ax.ticks()[0] (-4.0, '0.0') >>> ax.useLogScale = False >>> ax.ticks()[0] (0.0625, '0.0') ''' s = self.stream if not s: return [] elif self.client.recurse: sSrc = s.recurse() else: sSrc = s.iter sSrc = sSrc.getElementsByClass(self.client.classFilterList) # get all quarter lengths mapping = elementAnalysis.attributeCount(sSrc, 'quarterLength') ticks = [] for ql in sorted(mapping): x = self.dataFromQL(ql) if self.useDurationNames: label = duration.Duration(ql).fullName else: label = str(round(ql, 2)) ticks.append((x, label)) return ticks
def ticks(self): ''' Get ticks for quarterLength. If `remap` is `True` (the default), the `remapQuarterLength()` method will be used to scale displayed quarter lengths by log base 2. Note that mix and max do nothing, but must be included in order to set the tick style. >>> s = stream.Stream() >>> for t in ['32nd', '16th', 'eighth', 'quarter', 'half']: ... n = note.Note() ... n.duration.type = t ... s.append(n) >>> plotS = graph.plot.PlotStream(s) >>> ax = graph.axis.QuarterLengthAxis(plotS) >>> ax.ticks() [(-3.0, '0.1...'), (-2.0, '0.25'), (-1.0, '0.5'), (0.0, '1.0'), (1.0, '2.0')] >>> ax.useLogScale = False >>> ax.ticks() [(0.125, '0.1...'), (0.25, '0.25'), (0.5, '0.5'), (1.0, '1.0'), (2.0, '2.0')] >>> ax.useDurationNames = True >>> ax.ticks() [(0.125, '32nd'), (0.25, '16th'), (0.5, 'Eighth'), (1.0, 'Quarter'), (2.0, 'Half')] The second entry is 0.125 but gets rounded differently in python 2 (1.3) and python 3 (1.2) >>> nGrace = note.Note() >>> nGrace.getGrace(inPlace=True) >>> s.append(nGrace) >>> plotS = graph.plot.PlotStream(s) >>> ax = graph.axis.QuarterLengthAxis(plotS) >>> ax.ticks()[0] (-4.0, '0.0') >>> ax.useLogScale = False >>> ax.ticks()[0] (0.0625, '0.0') ''' s = self.stream if not s: return [] elif self.client.recurse: sSrc = s.recurse() else: sSrc = s.iter sSrc = sSrc.getElementsByClass(self.client.classFilterList) # get all quarter lengths mapping = elementAnalysis.attributeCount(sSrc, 'quarterLength') ticks = [] for ql in sorted(mapping): x = self.dataFromQL(ql) if self.useDurationNames: label = duration.Duration(ql).fullName else: label = str(round(ql, 2)) ticks.append((x, label)) return ticks