|
From: pieter c. <pi...@cl...> - 2005-02-03 08:22:54
|
Andre, I had a go at looking at your code, but without understanding the larger implementation, I am lost. However, I am interested in this and will have a go at it again later. A few questions if I may (this might be answered earlier in the list, so tell me to stop if that is the case): 1. How does pyx make use of TeX? What is the integration and purpose of the integration? 2. What is the basic idea behind the library design? I can see from the documentation the basic workflow, but what about the underlying principles for the implementation? As to labels and tics: This I think is a difficult subject because in many libraries it is not an easy subject and the implementor requires a significant amount of knowledge to do anything other than use defaults. To make it more user friendly, I have the following suggestions (and will help implement where I can) 1. To develop a number of use-cases and appropriate examples for manual overried that include: 1.1. Example of no labels on all types graphs 1.2. Example of manual labels on all types of graphs 1.3. ... 2. Would it be possible to provide a manual override parameter to all axis that allows users to provide a list of values or [[value,label],..] that will then be converted to chart-coordinates and plotted at value location on the axis? This would provide ultimate flexibility. I have been thinking about a first set of requirements for the histogram class and here is my stab at them. REQUIRED 1. To plot steps like gnuplot. 2. To plot multiple series on a graph. 3. To provide manual overrides on the x-axis. 4. To cater for both continuous as well as discreet x-values (this again is a little unclear but I can imagine that not all statistical sampling would be agains continues values) DESIRED 1. To provide the facility to swap axis (this I cannot justify, but can imagine that it would be valuable. http://en.wikipedia.org/wiki/Histogram Pieter > Hi Pieter, > > welcome on pyx-dev (which is kind of low traffic most of the time as > pyx-user as well) ... ;-) > > On 02.02.05, pieter claassen wrote: >> 1. Top plot this data so that it can be seen that there were 55 trips >> that >> took 95 minutes and 45 minutes that took 100 minutes. >> 2. To show that the distribution of the results are mostly on the high >> end. >> >> To recap the current problem: >> When this large number of data points are plotted on a bar graph, the >> x-axis labels overwrite each other. >> >> Current suggested solution: >> ?? > > Well, not really. As I said before, you should try to use a x-y-plot > for that. A bar graph is just the wrong thing for that. > >> Any suggestions on how to proceed? > > You'll need a histogram style. There are basically two ways to get it. > You could create a style from graph.style.linestyle, overwrite the > drawpoint method and call the graph.style.linestyle's drawpoint > several times for each point with appropriately modified > sharedata.vposi data to get the step-like shape. The other possibility > would be to write your own style from scratch. A simple, first working > example could look like: > > import random > from pyx import * > > class histogram(graph.style._styleneedingpointpos): > > needsdata = ["vpos", "vposmissing", "vposavailable"] > > defaultlineattrs = [] > > def __init__(self, lineattrs=[]): > self.lineattrs = lineattrs > > def selectstyle(self, privatedata, sharedata, graph, selectindex, > selecttotal): > if self.lineattrs is not None: > privatedata.lineattrs = > attr.selectattrs(self.defaultlineattrs + self.lineattrs, > selectindex, selecttotal) > else: > privatedata.lineattrs = None > > def initdrawpoints(self, privatedata, sharedata, graph): > privatedata.path = path.path() > privatedata.lastvpos = None > > def drawpoint(self, privatedata, sharedata, graph): > if sharedata.vposavailable: > if privatedata.lastvpos: > midvxpos = 0.5 * (privatedata.lastvpos[0] + > sharedata.vpos[0]) > privatedata.path.append(path.lineto_pt(*graph.vpos_pt(midvxpos, > privatedata.lastvpos[1]))) > privatedata.path.append(path.lineto_pt(*graph.vpos_pt(midvxpos, > 0))) > privatedata.path.append(path.lineto_pt(*graph.vpos_pt(midvxpos, > sharedata.vpos[1]))) > privatedata.path.append(path.lineto_pt(*graph.vpos_pt(*sharedata.vpos))) > else: > privatedata.path.append(path.moveto_pt(*graph.vpos_pt(*sharedata.vpos))) > privatedata.lastvpos = sharedata.vpos[:] > else: > privatedata.lastvpos = None > > def donedrawpoints(self, privatedata, sharedata, graph): > if privatedata.lineattrs is not None and > len(privatedata.path.path): > graph.stroke(privatedata.path, privatedata.lineattrs) > > > g = graph.graphxy(width=8) > g.plot(graph.data.list([(5*i, random.random()) for i in range(1, 20)], > x=1, y=2), [histogram()]) > g.writeEPSfile("histogram") > > > However, its just a starting point. We do not correctly adjust the > vertical range. We do not know how to handle the edge points > (currently particial boxes are plotted --- we could, of course, just > plot steps (like gnuplot and others, but I'm not sure whether this is > a good idea)). We do not cut the path at the graph border. We can't > exchange x and y axis ... etc. > > Any comments how to proceed? What's needed out there? (I do not need > histograms at all, otherwise I would have implemented such a style > before already, but since we're now on the subject, we might get it > done once and for all ...) Although its working well that way, its not > that easy to make it a robust graph style. As usual with graph styles. > Its easy to implement one, but to make it general perpose, some more > work needs to be done ... > > > André > > -- > by _ _ _ Dr. André Wobst > / \ \ / ) wo...@us..., http://www.wobsta.de/ > / _ \ \/\/ / PyX - High quality PostScript figures with Python & TeX > (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting > Tool for open source databases. Create drag-&-drop reports. Save time > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. > Download a FREE copy at http://www.intelliview.com/go/osdn_nl > _______________________________________________ > PyX-devel mailing list > PyX...@li... > https://lists.sourceforge.net/lists/listinfo/pyx-devel > |