@@ -31,12 +31,13 @@ The output of tikzplotlib is in
3131top of [ PGF/TikZ] ( https://en.wikipedia.org/wiki/PGF/TikZ ) and describes graphs in terms
3232of axes, data etc. Consequently, the output of tikzplotlib
3333
34- * retains more information,
35- * can be more easily understood, and
36- * is more easily editable
34+ - retains more information,
35+ - can be more easily understood, and
36+ - is more easily editable
3737
3838than [ raw TikZ output] ( https://matplotlib.org/users/whats_new.html#pgf-tikz-backend ) .
3939For example, the matplotlib figure
40+
4041``` python
4142import matplotlib.pyplot as plt
4243import numpy as np
@@ -67,6 +68,7 @@ mpl.rcParams.update(mpl.rcParamsDefault)
6768```
6869-->
6970(see above) gives
71+
7072``` latex
7173\begin{tikzpicture}
7274
@@ -108,6 +110,7 @@ table {%
108110
109111\end{tikzpicture}
110112```
113+
111114(Use ` get_tikz_code() ` instead of ` save() ` if you want the code as a string.)
112115
113116Tweaking the plot is straightforward and can be done as part of your TeX work flow.
@@ -121,33 +124,39 @@ Notably, [3D plots don't work](https://github.com/matplotlib/matplotlib/issues/7
121124
122125tikzplotlib is [ available from the Python Package
123126Index] ( https://pypi.org/project/tikzplotlib/ ) , so simply do
127+
124128```
125129pip install tikzplotlib
126130```
127- to install.
128131
132+ to install.
129133
130134### Usage
131135
1321361 . Generate your matplotlib plot as usual.
133137
1341382 . Instead of ` pyplot.show() ` , invoke tikzplotlib by
139+
135140 ``` python
136141 import tikzplotlib
137142
138143 tikzplotlib.save(" mytikz.tex" )
139144 # or
140145 tikzplotlib.save(" mytikz.tex" , flavor = " context" )
141146 ```
142- to store the TikZ file as `mytikz.tex` .
147+
148+ to store the TikZ file as `mytikz.tex` .
143149
1441503 . Add the contents of `mytikz.tex` into your TeX source code. A convenient way of
145151 doing so is via
152+
146153 ```latex
147154 \input{/path/to/mytikz.tex}
148155 ```
149- Also make sure that the packages for PGFPlots and proper Unicode support and are
150- included in the header of your document:
156+
157+ Also make sure that the packages for PGFPlots and proper Unicode support and are
158+ included in the header of your document:
159+
151160 ```latex
152161 \usepackage[utf8]{inputenc}
153162 \usepackage{pgfplots}
@@ -156,7 +165,9 @@ to install.
156165 \usetikzlibrary{patterns,shapes.arrows}
157166 \pgfplotsset{compat=newest}
158167 ```
159- or :
168+
169+ or :
170+
160171 ```latex
161172 \setupcolors[state=start]
162173 \usemodule[tikz]
@@ -167,7 +178,9 @@ to install.
167178 \unexpanded\def\startgroupplot{\groupplot}
168179 \unexpanded\def\stopgroupplot{\endgroupplot}
169180 ```
170- You can also get the code via:
181+
182+ You can also get the code via:
183+
171184 ```python
172185 import tikzplotlib
173186
@@ -177,6 +190,7 @@ to install.
177190 ```
178191
1791924 . Optional: clean up the figure before exporting to tikz using the `clean_figure` command.
193+
180194 ```python
181195 import matplotlib.pyplot as plt
182196 import numpy as np
@@ -188,9 +202,10 @@ to install.
188202 tikzplotlib.clean_figure()
189203 tikzplotlib.save(" test.tex" )
190204 ```
205+
191206 The command will remove points that are outside the axes limits, simplify curves and
192207 reduce point density for the specified target resolution.
193-
208+
194209 The feature originated from the
195210 [matlab2tikz](https:// github.com/ matlab2tikz/ matlab2tikz) project and is adapted to
196211 matplotlib.
@@ -201,7 +216,6 @@ If you experience bugs, would like to contribute, have nice examples of what
201216tikzplotlib can do, or if you are just looking for more information, then please
202217visit [tikzplotlib' s GitHub page](https://github.com/nschloe/tikzplotlib).
203218
204-
205219# ## Testing
206220
207221tikzplotlib has automatic unit testing to make sure that the software doesn' t
@@ -210,6 +224,7 @@ Those run through tikzplotlib and compare the output with a previously stored
210224reference TeX file .
211225
212226To run the tests, just check out this repository and type
227+
213228```
214229pytest
215230```
0 commit comments