From 9d9b8eb7ed399f214b2561c7a06097a8a9639ad0 Mon Sep 17 00:00:00 2001 From: Michael Schindler Date: Tue, 25 Mar 2008 14:07:10 +0000 Subject: [PATCH] added an example for varying the symbol and line styles git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@2970 069f4177-920e-0410-937b-c2a4a81bcd90 --- examples/graphstyles/INDEX | 1 + examples/graphstyles/usesymbol.py | 18 ++++++++++++++++++ examples/graphstyles/usesymbol.txt | 11 +++++++++++ 3 files changed, 30 insertions(+) create mode 100644 examples/graphstyles/usesymbol.py create mode 100644 examples/graphstyles/usesymbol.txt diff --git a/examples/graphstyles/INDEX b/examples/graphstyles/INDEX index 82f1d034..3cd0a0d4 100644 --- a/examples/graphstyles/INDEX +++ b/examples/graphstyles/INDEX @@ -1,4 +1,5 @@ errorbar histogram +usesymbol changesymbol cal diff --git a/examples/graphstyles/usesymbol.py b/examples/graphstyles/usesymbol.py new file mode 100644 index 00000000..91c04a2d --- /dev/null +++ b/examples/graphstyles/usesymbol.py @@ -0,0 +1,18 @@ +from pyx import * + +# colors and symbols to use (alternatingly) +colors = [color.rgb.red, color.rgb.green, color.rgb.blue, color.gray.black] +symbols = [graph.style._diamondsymbol, graph.style._trianglesymbol, graph.style._circlesymbol] + +# create the graph styles to be used below +symbol = graph.style.symbol(symbol=attr.changelist(symbols), + symbolattrs=[deco.stroked.clear, + attr.changelist([deco.filled([cc]) for cc in colors])]) +line = graph.style.line(lineattrs=[attr.changelist(colors), + attr.changelist([style.linestyle.solid])]) + +g = graph.graphxy(width=8, x=graph.axis.linear(min=0, max=1)) +g.plot([graph.data.function("y(x) = x**%d" % i, points=8) for i in range(1, 7)], + styles=[line, symbol]) +g.writeEPSfile("usesymbol") +g.writePDFfile("usesymbol") diff --git a/examples/graphstyles/usesymbol.txt b/examples/graphstyles/usesymbol.txt new file mode 100644 index 00000000..5f0bed4c --- /dev/null +++ b/examples/graphstyles/usesymbol.txt @@ -0,0 +1,11 @@ +Using the functionality of existing graph styles + +This example demonstrates how linestyles, symboltypes, colors, and other +decorations can be changed in existing graph styles. ... We make use of the +`changelist' feature as an argument when using a style. Generally, all items in +the attribute lists can be iterable `changelists'. If the end of such a list is +reached, the changelist restarts from its beginning (see e.g. the colors which +are used several times). + +The `attr.stroked.clear' in the symbol deletes the default property of the +symbols, which says to stroke the symbol outline. -- 2.11.4.GIT