Skip to content

Commit 84be26c

Browse files
committed
more concise readme
1 parent 1401984 commit 84be26c

File tree

1 file changed

+30
-57
lines changed

1 file changed

+30
-57
lines changed

README.md

Lines changed: 30 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ This is matplotlib2tikz, a Python tool for converting matplotlib figures into
1818
for native inclusion into LaTeX documents.
1919

2020
The output of matplotlib2tikz is in
21-
[PGFPlots](http://pgfplots.sourceforge.net/pgfplots.pdf), a LaTeX library that
22-
sits on top of TikZ and describes graphs in terms of axes, data etc.
23-
Consequently, the output of matplotlib2tikz retains more information, can be
24-
more easily understood, and is more easily editable than [raw TikZ output](https://matplotlib.org/users/whats_new.html#pgf-tikz-backend).
21+
[PGFPlots](http://pgfplots.sourceforge.net/pgfplots.pdf), a LaTeX library that sits on
22+
top of [PGF/TikZ](https://en.wikipedia.org/wiki/PGF/TikZ) and describes graphs in terms
23+
of axes, data etc. Consequently, the output of matplotlib2tikz
24+
* retains more information,
25+
* can be more easily understood, and
26+
* is more easily editable
27+
than [raw TikZ output](https://matplotlib.org/users/whats_new.html#pgf-tikz-backend).
2528
For example, the matplotlib figure
2629
```python,test
2730
import matplotlib.pyplot as plt
@@ -45,26 +48,25 @@ tikz_save("test.tex")
4548
```
4649
(see above) gives
4750
```latex
48-
% This file was created by matplotlib2tikz vx.y.z.
4951
\begin{tikzpicture}
5052
51-
\definecolor{color1}{rgb}{0.203921568627451,0.541176470588235,0.741176470588235}
5253
\definecolor{color0}{rgb}{0.886274509803922,0.290196078431373,0.2}
54+
\definecolor{color1}{rgb}{0.203921568627451,0.541176470588235,0.741176470588235}
5355
5456
\begin{axis}[
55-
title={Simple plot $\frac{\alpha}{2}$},
56-
xlabel={time (s)},
57-
ylabel={Voltage (mV)},
58-
xmin=-0.095, xmax=1.995,
59-
ymin=-1.1, ymax=1.1,
57+
axis background/.style={fill=white!89.80392156862746!black},
58+
axis line style={white},
6059
tick align=outside,
6160
tick pos=left,
62-
xmajorgrids,
61+
title={Simple plot $\frac{\alpha}{2}$},
6362
x grid style={white},
64-
ymajorgrids,
63+
xlabel={time (s)},
64+
xmajorgrids,
65+
xmin=-0.095, xmax=1.995,
6566
y grid style={white},
66-
axis line style={white},
67-
axis background/.style={fill=white!89.803921568627459!black}
67+
ylabel={Voltage (mV)},
68+
ymajorgrids,
69+
ymin=-1.1, ymax=1.1
6870
]
6971
\addplot [line width=1.64pt, color0, mark=*, mark size=3, mark options={solid}]
7072
table {%
@@ -92,7 +94,7 @@ work flow.
9294
contains great examples of how to make your plot look even better.
9395

9496
Of course, not all figures produced by matplotlib can be converted without error.
95-
Notably, [3D plot don't work](https://github.com/matplotlib/matplotlib/issues/7243).
97+
Notably, [3D plots don't work](https://github.com/matplotlib/matplotlib/issues/7243).
9698

9799
### Installation
98100

@@ -111,54 +113,25 @@ to install/update.
111113

112114
2. Instead of `pyplot.show()`, invoke matplotlib2tikz by
113115
```python
114-
tikz_save('mytikz.tex')
115-
```
116-
to store the TikZ file as `mytikz.tex`. Load the library with:
117-
```python
118-
from matplotlib2tikz import save as tikz_save
119-
```
120-
_Optional:_
121-
The scripts accepts several options, for example `height`, `width`,
122-
`encoding`, and some others. Invoke by
123-
```python
124-
tikz_save('mytikz.tex', figureheight='4cm', figurewidth='6cm')
125-
```
126-
Note that height and width must be set large enough; setting it too low may
127-
result in a LaTeX compilation failure along the lines of `Dimension Too Large` or `Arithmetic Overflow`;
128-
see information about these errors in [the PGFPlots manual](http://pgfplots.sourceforge.net/pgfplots.pdf).
129-
To specify the dimension of the plot from within the LaTeX document, try
130-
```python
131-
tikz_save(
132-
'mytikz.tex',
133-
figureheight='\\figureheight',
134-
figurewidth='\\figurewidth'
135-
)
116+
import matplotlib2tikz
117+
matplotlib2tikz.save("mytikz.tex")
136118
```
137-
and in the LaTeX source
119+
to store the TikZ file as `mytikz.tex`.
120+
121+
3. Add the contents of `mytikz.tex` into your LaTeX source code. A convenient way of
122+
doing so is via
138123
```latex
139-
\newlength\figureheight
140-
\newlength\figurewidth
141-
\setlength\figureheight{4cm}
142-
\setlength\figurewidth{6cm}
143-
\input{mytikz.tex}
124+
\input{/path/to/mytikz.tex}
144125
```
145-
146-
3. Add the contents of `mytikz.tex` into your LaTeX source code; a convenient
147-
way of doing so is via `\input{/path/to/mytikz.tex}`. Also make sure that
148-
in the header of your document the packages for PGFPlots and proper Unicode
149-
support and are included:
126+
Also make sure that the packages for PGFPlots and proper Unicode support and are
127+
included in the header of your document:
150128
```latex
151129
\usepackage[utf8]{inputenc}
130+
\usepackage{fontspec} % optional
152131
\usepackage{pgfplots}
153-
```
154-
Additionally, with LuaLaTeX
155-
```latex
156-
\usepackage{fontspec}
157-
```
158-
is needed to typeset Unicode characters.
159-
Optionally, to use the latest PGFPlots features, insert
160-
```latex
161132
\pgfplotsset{compat=newest}
133+
\usepgfplotslibrary{groupplots}
134+
\usepgfplotslibrary{dateplot}
162135
```
163136

164137
### Contributing

0 commit comments

Comments
 (0)