File: chunks.rst

package info (click to toggle)
python-pweave 0.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,064 kB
  • sloc: python: 30,281; makefile: 167
file content (111 lines) | stat: -rw-r--r-- 3,598 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Code Chunk Options
__________________

Pweave currently has the following options for processing the code
chunks.

.. envvar:: name, label

   If the first option of chunk is unnamed it will become the chunk
   name, you can also set the chunk name using the name or label (*for
   Sweave compatibility*) keys. All of these definitions are equal
   ``<<analysis, Fig = True>>=``,  ``<<Fig = True, name =
   'analysis'>>=``,  ``<<Fig = True, label = 'analysis'>>=``. Chunk
   names are used for figure names, but expanding named chunks in the
   Pweave todo list.

.. versionadded:: 0.2

.. envvar:: echo = True or (False)

   Echo the python code in the output document. If False the source
   code will be hidden.

.. envvar:: evaluate = True or (False).

   Evaluate the code chunk. If False the chunk won't be executed.

.. envvar:: results = 'verbatim'

   The output format of the printed results. 'verbatim' for literal
   block, 'hidden' for hidden results or anything other string for raw
   output (I tend to use 'tex' for Latex and 'rst' for rest. Raw output
   is useful if you wan't to e.g. create tables from code chunks.

.. versionadded:: 0.12

.. envvar:: term = False or (True)

   If True the output emulates a terminal session. The code will be executed
   one statement at a time and the output for each statement will be displayed.

.. envvar:: include = True or (False)

   If include is True generated figures are automatically included in
   the document otherwise figures are generated, but not
   included. This is useful if you want more control over figure
   formatting e.g. use subfigures in Latex.

.. versionadded:: 0.21

.. envvar:: fig = True or (False)

   Whether a matplotlib plot produced by the code chunk should be
   included in the file. The figure will be added with '.. image::'
   directive in .rst and \\includegraphics tag in .tex documents. See
   the 'caption' option if you want to use figure environment. As of
   version 0.21 Pweave supports multiple figures per code chunk.

.. envvar:: caption = ''

      A string providing a caption for the figure produced in the code
      chunk. Can only be used with 'fig = True' option.

.. envvar:: width

   The width of the created figure in the document (using format specific
   markup e.g. "12cm", "600px", "\linewidth"). The default width depends on the output format.

.. envvar:: f_size = (8,6)

  Saved matplotlib figure size in inches a tuple (w, h).

.. versionadded:: 0.22

.. envvar:: f_spines = True

  Removes spines from matplotlib figures right and top if False.

.. versionadded:: 0.22

.. envvar:: f_env

  Add environment that goes around figures in LaTex output e.g. sidefigure

.. versionadded:: 0.22

.. envvar:: f_pos = "htpb"

   Sets the figure position for latex figures.

.. versionadded:: 0.21

.. envvar:: wrap = True or (False,"code", "results")

   Controls wrapping of long lines. If True both code and output are
   wrapped to 75 characters. You can also specify "code" or "results" options to
   wrap only input or output.

.. versionadded:: 0.21

.. envvar:: complete = True

  Used to include code spanning multiple chunks before it get executed. Useful for e.g. documenting class definitions. Use complete = False all but the last chunk and set the last one as complete = True. Pweave executes all of the chunks together and includes the results after the last one. See:  :ref:`multi-chunk-example` example.

.. versionadded:: 0.22

.. envvar:: source

    Read chunk contents from file or python module or file. e.g. source = "mychunk.py".

.. versionadded:: 0.22