From: André W. <co...@wo...> - 2020-06-10 04:06:49
|
Hi, PyX 0.14.1 or PyX 0.15 ... should not make any difference. The problem is, that PyX has no support for time, date, or datetime axes. (It should be possible to change that, but for now ... sorry.) Using xnames requires a bar axis. This has major drawbacks, like being positioned equal distant in the order as provided. But heck, yes, it is possible with just a very few changes: 1. You need a tuple, with a position on the subaxis for the "bar" value. 2. You need to set a range for the subaxes, like 0 to 1, as you do not have a bar style in use. (The bar would automatically request this range and thus work without the hustle.) This means, the following works: ---------------------- ts=['13:00','13:15','13:30','13:45','14:00','14:15','14:30'] tsm=[(x, 0.5) for x in ts] waittime = [560, 580, 540, 800, 1000, 600, 560] attrs = [color.gradient.RedBlue] g = graph.graphxy(width=10, x=graph.axis.bar(defaultsubaxis=graph.axis.lin(min=0, max=1, painter=None, linkpainter=None, parter=None)), key=graph.key.key()) g.plot(graph.data.values(x=tsm, y=waittime), [graph.style.line(attrs), graph.style.symbol(graph.style.symbol.changesquare, symbolattrs=attrs, size=0.1)]) g.writeEPSfile("waittime") g.writePDFfile("waittime") ----------------------- However, I am not confident, that this a solution to go for. It might be, depending on your use case. Otherwise, well, you need to convert to numbers (and back for the labels) yourself. :-( Best, André Am 09.06.20 um 15:38 schrieb Martín Marqués: > Hi, > > > and welcome to the PyX club :) > > > Not the best way to join the club by forgetting to add a subject. :( > > The current version of PyX is 0.15 for the Fedora rpm, by the way. > Independent of that: > > > Maybe because I'm still on Fedora 30. I installed the packages > yesterday, so seems that the last available version here. Plans to move > to F32 are on my TODO > > Presumably, your ts is not a list of numbers but strings (labels). You > probably want to convert them or use them as labels by using > `xname=ts` instead of `x=ts`. > > > Oh my! Didn't have that. And yes, ts is a list of str with the time of > the occurrence that is stored in fulldata["waittime"] > Now it fails in a completely different way. :-D > > Code snippet with actual data to test: > > ``` > ts=['13:00','13:15','13:30','13:45','14:00','14:15','14:30'] > > waittime = [560, 580, 540, 800, 1000, 600, 560] > > attrs = [color.gradient.RedBlue] > > g = graph.graphxy(width=600, key=graph.key.key()) > > g.plot(graph.data.values(xname=ts, y=waittime), > [graph.style.line(attrs), > graph.style.symbol(graph.style.symbol.changesquare, > symbolattrs=attrs, size=0.1)]) > > g.writeEPSfile("waittime") > g.writePDFfile("waittime") > ``` > > ``` > Traceback (most recent call last): > File "build_graf.py", line 61, in <module> > graph.style.symbol(graph.style.symbol.changesquare, > symbolattrs=attrs, size=0.1)]) > File "/usr/lib64/python3.7/site-packages/pyx/graph/graph.py", line > 215, in plot > plotitems.append(plotitem(self, d, styles)) > File "/usr/lib64/python3.7/site-packages/pyx/graph/graph.py", line > 93, in __init__ > self.usedcolumnnames.update(set(s.columnnames(privatedata, > self.sharedata, graph, self.data.columnnames, self.dataaxisnames))) > File "/usr/lib64/python3.7/site-packages/pyx/graph/style.py", line > 440, in columnnames > raise ValueError("incomplete position information") > ValueError: incomplete position information > ``` > > Regards, Martín > > -- > Martín Marqués > It’s not that I have something to hide, > it’s that I have nothing I want you to see > > > _______________________________________________ > PyX-user mailing list > PyX...@li... > https://lists.sourceforge.net/lists/listinfo/pyx-user > -- by _ _ _ / \ \ / ) Dr. André Wobst, co...@wo..., https://www.wobsta.de / _ \ \/\/ / wobsta GmbH, Amselweg 22, 85716 Unterschleißheim, Germany (_/ \_)_/\_/ Office: +49 (0)89 5480 3394, Mobile: +49 (0)160 9380 4217 |