Re: [PyX-user] Integer axis in graphs From: Axel Freyn - 2007-09-30 15:36:57 ```Hi André, Andre Wobst wrote: > Hi, > > On 26.09.07, Axel Freyn wrote: >> I would like to have something like a "mintickdists", to guarantee that e.g. only Integers are used by the parter. > > Yes, that's what I would do too. You could also try to fiddle with the > rating, but this could easily lead to cases, where no valid partitions > are found anymore. Better change the parter. Here we go: > [...] thank you! I tried it today, and it works - at least for my example. > - There was a bug introduced in changeset 2592, where I accidentally > removed the range rating. Fixed in changeset 2882. Unfortunately I > released this buggy code in 0.9, but we'll have a 0.10 soon anyway. I'm waiting for 0.10 ;-) Axel -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer ```
 Re: [PyX-user] Integer axis in graphs From: Axel Freyn - 2007-09-26 06:39:39 ```Hi James, >Hi Axel, > >> > In my actual problem, depending on the size of the graph and >> > the size of the fonts, i get sometimes >> > 0,5,10,15,20 (which is exactly what I want) >> > and sometimes >> > 0,2.5,5,7.5,10,12.5,15,17.5,20. > > the "tickdists" argument to the partitioner is what you want. Have a > look at this program: if you remove the parts about p and xaxis, you > should see the non-integer ticks appearing. > > --- >#!/usr/bin/env python > >from pyx import * > >d = [[0, 1], [3, 4], [2, 6], [5, 2], [6, 3]] > >p = graph.axis.parter.linear(tickdists=[1]) >xaxis = graph.axis.linear(parter=p) >g = graph.graphxy(width=4.5, x=xaxis) >g.plot(graph.data.list(d, x=1, y=2)) >g.writeEPSfile("test") >--- Thank you for your proposal, but it is not exactly what I want;-) My problem with tickdists is, that it switches off the automatic partitioner: Using d = [[0, 1], [3, 4], [2, 6], [5, 2], [200, 3]] in your example does not look very nice... I would like to have something like a "mintickdists", to guarantee that e.g. only Integers are used by the parter. Axel -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser ```
 Re: [PyX-user] Integer axis in graphs From: Axel Freyn - 2007-09-30 15:36:57 ```Hi André, Andre Wobst wrote: > Hi, > > On 26.09.07, Axel Freyn wrote: >> I would like to have something like a "mintickdists", to guarantee that e.g. only Integers are used by the parter. > > Yes, that's what I would do too. You could also try to fiddle with the > rating, but this could easily lead to cases, where no valid partitions > are found anymore. Better change the parter. Here we go: > [...] thank you! I tried it today, and it works - at least for my example. > - There was a bug introduced in changeset 2592, where I accidentally > removed the range rating. Fixed in changeset 2882. Unfortunately I > released this buggy code in 0.9, but we'll have a 0.10 soon anyway. I'm waiting for 0.10 ;-) Axel -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer ```
 Re: [PyX-user] Integer axis in graphs From: Andre Wobst - 2007-09-26 08:53:33 ```Hi, On 26.09.07, Axel Freyn wrote: > I would like to have something like a "mintickdists", to guarantee that e.g. only Integers are used by the parter. Yes, that's what I would do too. You could also try to fiddle with the rating, but this could easily lead to cases, where no valid partitions are found anymore. Better change the parter. Here we go: #!/usr/bin/env python from pyx import * d = [[0, 1], [3, 4], [2, 6], [5, 2], [6, 3]] class intparter(graph.axis.parter.autolin): def partfunction(self, data, testint=1): if data.sign == 1: if data.tickindex < len(self.variants) - 1: data.tickindex += 1 else: data.tickindex = 0 data.base.num *= 10 else: if data.tickindex: data.tickindex -= 1 else: data.tickindex = len(self.variants) - 1 data.base.denom *= 10 tickdists = [graph.axis.tick.rational(t) * data.base for t in self.variants[data.tickindex]] linearparter = graph.axis.parter.linear(tickdists=tickdists, extendtick=self.extendtick, epsilon=self.epsilon) if testint: tests = 0 while tests < len(self.variants) or data.sign == 1: if not tests: ticks = linearparter.partfunctions(min=data.min, max=data.max, extendmin=data.extendmin, extendmax=data.extendmax)[0]() else: ticks = self.partfunction(data, testint=0) for tick in ticks: # if tick.labellevel is not None and tick.num % tick.denom: # labeled ticks are integer if tick.num % tick.denom: # all ticks are integer break else: return ticks tests += 1 return None else: return linearparter.partfunctions(min=data.min, max=data.max, extendmin=data.extendmin, extendmax=data.extendmax)[0]() intaxis = graph.axis.linear(parter=intparter()) g = graph.graphxy(width=4.5, x=intaxis) g.plot(graph.data.list(d, x=1, y=2)) g.writeEPSfile("test") Some random notes: - You can decide whether you want to allow (sub-)ticks at non-integer values or whether all ticks should be integers (see the comment in the code). - The parter does not just stop for non-integer ticks, since it could be, that you have a partition with at tick at 2.5, but there are other integer partitions available for smaller ticks. - We could force integer bases by adjusting the partfunctions method as well. Could gain speed in some cases, but would not lead to any different result. - There was a bug introduced in changeset 2592, where I accidentally removed the range rating. Fixed in changeset 2882. Unfortunately I released this buggy code in 0.9, but we'll have a 0.10 soon anyway. Sorry for breaking the rating another time, back to as it was intended and worked in 0.8 and earlier. (I do have the intension, that the automatic partitioning should not change from version to version, but as you see, I'm missing that goal from time to time.) http://pyx.svn.sourceforge.net/viewvc/pyx/trunk/pyx/pyx/graph/axis/axis.py?r1=2542&r2=2592 http://pyx.svn.sourceforge.net/viewvc/pyx/trunk/pyx/pyx/graph/axis/axis.py?r1=2808&r2=2884 André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```