From 6cb70d76887b19a705dd05d9fcd6f159048d4301 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Wed, 24 May 2006 09:34:24 +0000 Subject: [PATCH] add example documentation to the graph styles git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@2806 069f4177-920e-0410-937b-c2a4a81bcd90 --- examples/graphstyles/cal.py | 5 ----- examples/graphstyles/cal.txt | 5 +++++ examples/graphstyles/changesymbol.py | 3 --- examples/graphstyles/changesymbol.txt | 10 ++++++++++ examples/graphstyles/errorbar.txt | 32 ++++++++++++++++++++++++++++++++ examples/graphstyles/histogram.txt | 14 ++++++++++++++ 6 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 examples/graphstyles/cal.txt create mode 100644 examples/graphstyles/changesymbol.txt create mode 100644 examples/graphstyles/errorbar.txt create mode 100644 examples/graphstyles/histogram.txt diff --git a/examples/graphstyles/cal.py b/examples/graphstyles/cal.py index efb77714..0d72e10d 100644 --- a/examples/graphstyles/cal.py +++ b/examples/graphstyles/cal.py @@ -1,8 +1,3 @@ -# In this example we create a calendar graph style. The style uses -# bar axes for both graph coordinates and it is a simple and minimal -# example in the sense that it does not make use of other styles -# for positioning. - import calendar from pyx import * diff --git a/examples/graphstyles/cal.txt b/examples/graphstyles/cal.txt new file mode 100644 index 00000000..8588a2eb --- /dev/null +++ b/examples/graphstyles/cal.txt @@ -0,0 +1,5 @@ +Making a calendar graph + +!! In this example we create a calendar graph style. The style uses bar axes +for both graph coordinates and it is a simple and minimal example in the sense +that it does not make use of other styles for positioning. diff --git a/examples/graphstyles/changesymbol.py b/examples/graphstyles/changesymbol.py index 9e43045a..8af45140 100644 --- a/examples/graphstyles/changesymbol.py +++ b/examples/graphstyles/changesymbol.py @@ -1,6 +1,3 @@ -# This example extends the symbol style of a graph to make -# the symbol size and color data dependent. - import random from pyx import * diff --git a/examples/graphstyles/changesymbol.txt b/examples/graphstyles/changesymbol.txt new file mode 100644 index 00000000..fd72519d --- /dev/null +++ b/examples/graphstyles/changesymbol.txt @@ -0,0 +1,10 @@ +Add functionality to existing graph styles + +! In this example demonstrate how graph styles can be modified to add further +functionality to them. ... Here we create changesymbol styles based on PyX's +symbol style. For that two additional column names are introduced that way, +that they can be modified in the constructor of the style. The column names are +then registered by the adjusted version of the `columnnames` method. After that +we only need to replace the drawpoint method by a modified version, which +implements the additional functionality. This new created style can than be +used like any other graph style. diff --git a/examples/graphstyles/errorbar.txt b/examples/graphstyles/errorbar.txt new file mode 100644 index 00000000..6b84206e --- /dev/null +++ b/examples/graphstyles/errorbar.txt @@ -0,0 +1,32 @@ +Combining several graph styles + +In this example several graph styles are applied one after the other to stroke +symbols and errorbars for the given data. This can be achieved by passing a +list of graph styles as the second parameter to the graph style. ... + +When you do set the second argument in the graphs plot command, default graph +styles are used to plot the data. The default for the graph styles depend is a +property of the data instance passed in the first argument of the plot command. +While the list and file data instances use a `graph.style.symbol` instance by +default, for functions and parametric functions a `graph.style.line` instance +is used. + +The style instances parse the column names for appropriate entries to generate +the corresponding output. In this case, the `x` and `y` values are used by +both, the symbol and the errorbar style, whereas `dy` is used by the +`errorbar` style only. + +! You could also provide data for `ymin` and `ymax` to the errorbar style +instead of `dy`. The errorbar style can also draw errorbars in x-direction +using `dx` or `xmin` and `xmax`. You can add errorbars in both graph directions +at the same time. + +!! The `x` and `y` data is not used by the symbol style nor the errorbar style +directly (except for calculating the minimal and maximal value in y-direction +by the errorbar due to the parametrization by `y` and `dy`). Instead a +positioning style is inserted implicitly (a instance of graph.style.pos) as a +position information is needed by the symbol and errorbar styles. By that the +styles don't need to perform certain operations several times. Additionally the +styles can also be used on graphs, which behave different in their positioning +properties like bar graphs where you can use the same styles by just using a +different positioning style. diff --git a/examples/graphstyles/histogram.txt b/examples/graphstyles/histogram.txt new file mode 100644 index 00000000..6f6cf5e1 --- /dev/null +++ b/examples/graphstyles/histogram.txt @@ -0,0 +1,14 @@ +Creating a histogram + +Styles can alter the way data is presented in arbitrary ways. Here the +histogram style is used to generate a histogram. ... By default the histogram +draws a box for each histogram value, but you can set the `step` parameter of +the histogram style to use steps instead. + +! In this basic use-case the histogram is calculated out of equal-spaced +x-values automatically. You can also use errorbar like data in one graph +dimension to generate histograms with different widths of the histogram boxes. + +! Note that a histogram is very different from a bar graph in that it uses +regular axes (like the default linear axes in this example) in both graph +dimensions. Instead, bar graphs use a discrete axis. -- 2.11.4.GIT