Skip to content

Commit b4fe40e

Browse files
committed
prettier readme
1 parent 6727dd1 commit b4fe40e

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

README.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ The output of tikzplotlib is in
3131
top of [PGF/TikZ](https://en.wikipedia.org/wiki/PGF/TikZ) and describes graphs in terms
3232
of 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

3838
than [raw TikZ output](https://matplotlib.org/users/whats_new.html#pgf-tikz-backend).
3939
For example, the matplotlib figure
40+
4041
```python
4142
import matplotlib.pyplot as plt
4243
import numpy as np
@@ -57,16 +58,20 @@ import tikzplotlib
5758

5859
tikzplotlib.save("test.tex")
5960
```
61+
6062
<!--close the figure and reset defaults
6163
<!--pytest-codeblocks:cont-->
64+
6265
```python
6366
import matplotlib as mpl
6467

6568
plt.close()
6669
mpl.rcParams.update(mpl.rcParamsDefault)
6770
```
71+
6872
-->
6973
(see above) gives
74+
7075
```latex
7176
\begin{tikzpicture}
7277
@@ -108,6 +113,7 @@ table {%
108113
109114
\end{tikzpicture}
110115
```
116+
111117
(Use `get_tikz_code()` instead of `save()` if you want the code as a string.)
112118

113119
Tweaking the plot is straightforward and can be done as part of your TeX work flow.
@@ -121,33 +127,39 @@ Notably, [3D plots don't work](https://github.com/matplotlib/matplotlib/issues/7
121127

122128
tikzplotlib is [available from the Python Package
123129
Index](https://pypi.org/project/tikzplotlib/), so simply do
130+
124131
```
125132
pip install tikzplotlib
126133
```
127-
to install.
128134

135+
to install.
129136

130137
### Usage
131138

132139
1. Generate your matplotlib plot as usual.
133140

134141
2. Instead of `pyplot.show()`, invoke tikzplotlib by
142+
135143
```python
136144
import tikzplotlib
137145

138146
tikzplotlib.save("mytikz.tex")
139147
# or
140148
tikzplotlib.save("mytikz.tex", flavor="context")
141149
```
142-
to store the TikZ file as `mytikz.tex`.
150+
151+
to store the TikZ file as `mytikz.tex`.
143152

144153
3. Add the contents of `mytikz.tex` into your TeX source code. A convenient way of
145154
doing so is via
155+
146156
```latex
147157
\input{/path/to/mytikz.tex}
148158
```
149-
Also make sure that the packages for PGFPlots and proper Unicode support and are
150-
included in the header of your document:
159+
160+
Also make sure that the packages for PGFPlots and proper Unicode support and are
161+
included in the header of your document:
162+
151163
```latex
152164
\usepackage[utf8]{inputenc}
153165
\usepackage{pgfplots}
@@ -156,7 +168,9 @@ to install.
156168
\usetikzlibrary{patterns,shapes.arrows}
157169
\pgfplotsset{compat=newest}
158170
```
159-
or:
171+
172+
or:
173+
160174
```latex
161175
\setupcolors[state=start]
162176
\usemodule[tikz]
@@ -167,7 +181,9 @@ to install.
167181
\unexpanded\def\startgroupplot{\groupplot}
168182
\unexpanded\def\stopgroupplot{\endgroupplot}
169183
```
170-
You can also get the code via:
184+
185+
You can also get the code via:
186+
171187
```python
172188
import tikzplotlib
173189

@@ -177,6 +193,7 @@ to install.
177193
```
178194

179195
4. Optional: clean up the figure before exporting to tikz using the `clean_figure` command.
196+
180197
```python
181198
import matplotlib.pyplot as plt
182199
import numpy as np
@@ -188,9 +205,10 @@ to install.
188205
tikzplotlib.clean_figure()
189206
tikzplotlib.save("test.tex")
190207
```
208+
191209
The command will remove points that are outside the axes limits, simplify curves and
192210
reduce point density for the specified target resolution.
193-
211+
194212
The feature originated from the
195213
[matlab2tikz](https://github.com/matlab2tikz/matlab2tikz) project and is adapted to
196214
matplotlib.
@@ -201,7 +219,6 @@ If you experience bugs, would like to contribute, have nice examples of what
201219
tikzplotlib can do, or if you are just looking for more information, then please
202220
visit [tikzplotlib's GitHub page](https://github.com/nschloe/tikzplotlib).
203221

204-
205222
### Testing
206223

207224
tikzplotlib has automatic unit testing to make sure that the software doesn't
@@ -210,6 +227,7 @@ Those run through tikzplotlib and compare the output with a previously stored
210227
reference TeX file.
211228

212229
To run the tests, just check out this repository and type
230+
213231
```
214232
pytest
215233
```

0 commit comments

Comments
 (0)