From: Andre W. <wo...@us...> - 2005-09-19 10:37:02
|
Hi, On 17.09.05, Alan G Isaac wrote: > 1. In order to graph relative to the axes, I use > graph.graphxy.pos quite a bit. Indeed, I would like to > be able to use it as follows: find an intersection > between two curves that are drawn relative to the axes > (i.e., using 'pos'), and then mark this intersection on > the axes with manual ticking (to take advantage of > 'tick'). But I have to 'dolayout' before I can use > 'pos', which I use to draw the curves, which I need to > draw to get the intersection. Can I add manual ticks > *after* 'dolayout'? You can just paint you own ticks yourself but it is not possible to add ticks etc. the way you just described. The reason is, that the partitioning (the calculation of automatic ticks) as well as the final decision about the axis range might depend on all the various parameters including manual ticks. This might sound overengineered, but by this we're truely able to use the best possible solution (as defined by a rater instance). The problem you have simply can't be solved automatically. You can stroke your own tick and typeset your own text but you need to ensure youself, that, for example, no overlaps between the different texts occur. Alternatively you could calculate the intersection in "problem coordinates" before starting to plot you stuff. But once you want to do intersect you final paths it's correct that the system does not allow you this to modify graph properties. Still I can show you how to create ticks with look like those created by the axis painter. It's basically a question to understand what the painter really does and what parameters it is using. The ticks have a certain length (given by the innerticklen and outerticklen attribute, some stroke styles -- all those things are selected as changeable attributes depending on the tick level (i.e. tick, subtick, subsubtick etc.)). The text is aligned similar to what's shown in the vector example (I know this alignment features are not really easy to understand and are not yet described on an end-user level -- sorry), has some fixed distance from the axis and certain text attributes. > Naturally I tried appending to the > manualticks, but that does not work. Another difficulty > is that tick.tick does not accept unit.length instances > and unit.length instances do not have a __float__ > attributes. Are these intentional? Yes. It's just because a tick position has nothing to do with canvas position. The tick position is measured in "problem coordinates" and hence the value of a tick is given in problem coordinates too. Compared to that stroking something yourself you need to do in canvas coordinates. The axis converts "problem coordinates" into "graph coordinates" (of range 0 to 1) and the graph converts the "graph coordinates" to lengths in canvas coordinates (and positions at the canvas). > 2. For speed, I work on my scripts in the Python > interpreter. I misspelled a LaTeX macro I am using, and > of course PyX warns me by helpfully returning the error > message from TeX. So I fix the error and try to rerun my > script from the interpreter. Python says: > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "c:\temp4.py", line 6, in ? > pyx.text.reset() > File "C:\Python24\lib\site-packages\pyx\text.py", line 1057, in reset > self.finishdvi() > File "C:\Python24\lib\site-packages\pyx\text.py", line 1050, in finishdvi > raise RuntimeError("end of dvifile expected") > RuntimeError: end of dvifile expected > > If I try again to run it, PyX will "waitfortex" forever. > At this point, I close the interpreter and start again. > Can I add something to my scripts to deal gracefully with > this? Could you give some simple example? It might also depend on the OS/TeX distro/whatever. We're basically in a bad situation, when TeX get's into a state we don't expect. We're trying to deal with this situation by still properly talking to TeX, but if TeX refuses to do so, we're in a bad situation. The point is, that we'll never kill the TeX process. But certain typical problems are solveable and we should try to do so. Let me give you an example: andre@pb:~/python/pyx$ python Python 2.3.3 (#1, Aug 23 2004, 20:06:57) [GCC 3.3 20030304 (Apple Computer, Inc. build 1640)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from pyx import * >>> text.text(0, 0, "This is \wrong!") Traceback (most recent call last): File "<stdin>", line 1, in ? File "/Users/andre/python/pyx/pyx/text.py", line 1200, in text self.execute(expr, self.defaulttexmessagesdefaultrun + self.texmessagesdefaultrun + texmessages) File "/Users/andre/python/pyx/pyx/text.py", line 1038, in execute raise TexResultError("unhandled TeX response (might be an error)", self) pyx.text.TexResultError: unhandled TeX response (might be an error) The expression passed to TeX was: \ProcessPyXBox{This is \wrong!% }{1}% \PyXInput{5}% After parsing the return message from TeX, the following was left: * *! Undefined control sequence. <argument> This is \wrong ! \ProcessPyXBox #1#2->\setbox \PyXBox =\hbox {{#1 (cut after 5 lines, increase errordebug for more output) >>> text.text(0, 0, "But this still works!") <pyx.text.textbox instance at 0x12b4e40> >>> I'm wondering what happens to you that you go into that end of dvifile error. Could you give some informations in what situations you're stepping into that problem? A minimal example similar to the one above might be interesting. André -- by _ _ _ Dr. André Wobst / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ |