Hi, you need to build a new graph style for that. As you can use errorbars for the whiskers, you only need to build the box, and this can be done similarly to the error bars, just plotting something different. Hence you just need to adjust the drawpoint method of this new style. If you restrict yourself to 2d, the code will be much simpler than what the errorbar code does originally. Here is a basic (but complete) example:
from pyx import *
class boxstyle(graph.style.errorbar):
def drawpoint(self, privatedata, sharedata, graph, point):
for i in privatedata.dimensionlist:
if sharedata.vrange[i] != [None, None]:
vminpos = sharedata.vpos[:]
vminpos[i] = sharedata.vrange[i][0]
vmaxpos = sharedata.vpos[:]
vmaxpos[i] = sharedata.vrange[i][1]
p = graph.vcap_pt(1-i, privatedata.errorsize_pt, *vminpos)
p.join(graph.vcap_pt(1-i, -privatedata.errorsize_pt, *vmaxpos))
p.append(path.closepath())
privatedata.errorbarcanvas.stroke(p)
privatedata.errorbarcanvas.stroke(graph.vcap_pt(1-i,
privatedata.errorsize_pt, *sharedata.vpos))
data = [(1, 0, 0.5, 1, 1.5, 2),
(2, 1, 1.5, 2, 2.5, 3)]
g = graph.graphxy(width=10, x=graph.axis.lin(min=0, max=3))
g.plot(graph.data.points(data, x=1, ymin=2, y=3), [graph.style.errorbar(1)])
g.plot(graph.data.points(data, x=1, y=5, ymax=6), [graph.style.errorbar(1)])
g.plot(graph.data.points(data, x=1, ymin=3, y=4, ymax=5), [boxstyle(1)])
g.writePDFfile()
Here I just draw the 3 components (lower whisker, higher whisker and the box)
separately. You could do it in a single plot command, as you can pass several
styles to a single plot command. However, to distinguish between the different
ranges, you would need to set usenames on the (in the show code implicit) range
style. To complicate this there is a bug (which I'll fix in a minute) due to
which it fails for absolute min and max values in the range style with usename
setting. I just found out about it as I tried to do it in a single plot
command. Anyway, it may not bother you too much to just use the above solution.
Alternatively you can always build a more individual (complicated) style
yourself drawing it all together.
Best
André
Am 21.09.2011 um 17:08 schrieb P V:
> Hi all,
>
> is there a way to create a box/whiskers (box plot) plot using pyx? My
> understanding is that there is no ``formal'' way to do it, but I'm looking
> for ideas...
>
> PV
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1_______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
--
by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
/ \ \ / ) [email protected], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________ PyX-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyx-user
