2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-19 11:38:05 +02:00

Linear functions: Added

This commit is contained in:
Martin Thoma 2020-09-09 22:43:05 +02:00
parent b69cf543cf
commit 98a1a72e78
No known key found for this signature in database
GPG key ID: CDBDEC5C1C911F05
7 changed files with 152 additions and 0 deletions

View file

@ -0,0 +1,37 @@
SOURCE = exponential-functions-gif
DELAY = 40
DENSITY = 300
WIDTH = 1000
make:
pdflatex $(SOURCE).tex -output-format=pdf
make clean
clean:
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot *.toc *.snm *.nav *.out
gif:
pdfcrop $(SOURCE).pdf
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
make clean
png:
make
make svg
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
transparentGif:
convert $(SOURCE).pdf -transparent white result.gif
make clean
animatedGif:
make
pdfcrop $(SOURCE).pdf
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
make clean
svg:
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
pdf2svg $(SOURCE).pdf $(SOURCE).svg
# Necessary, as pdf2svg does not always create valid svgs:
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg

View file

@ -0,0 +1,3 @@
Compiled example
----------------
![Example](exponential-functions-gif.png)

View file

@ -0,0 +1,41 @@
\documentclass[varwidth=false, border=2pt]{beamer}
\usepackage{tikz,pgfplots,multido}
\pgfplotsset{compat=1.17}
\usepackage{nicefrac}
\pgfplotsset{every axis legend/.append style={
at={(0,0)},
anchor=north east}}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\multido{\i=0+1}{10}{%
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,
axis y line=middle,
grid = major,
width=16cm,
height=8cm,
grid style={dashed, gray!30},
xmin=-2.1, % start the diagram at this x-coordinate
xmax= 4.1, % end the diagram at this x-coordinate
ymin= 0, % start the diagram at this y-coordinate
ymax= 17, % end the diagram at this y-coordinate
xlabel=$x$,
ylabel=$y$,
ytick={0,2,3,4,8,9,12,16},
yticklabels={0,2,3,4,8,9,12,16},
legend cell align=left,
legend pos=south east,
legend style={draw=none},
tick align=outside,
enlargelimits=false]
% plot the function
\addplot[domain=-2:{4*\i/10}, red, ultra thick,samples=500] {2^x};
\end{axis}
\end{tikzpicture}
}
\end{document}

View file

@ -0,0 +1,31 @@
SOURCE = linear-functions
DELAY = 80
DENSITY = 300
WIDTH = 500
make:
pdflatex $(SOURCE).tex -output-format=pdf
make clean
clean:
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
gif:
pdfcrop $(SOURCE).pdf
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
make clean
png:
make
make svg
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
transparentGif:
convert $(SOURCE).pdf -transparent white result.gif
make clean
svg:
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
pdf2svg $(SOURCE).pdf $(SOURCE).svg
# Necessary, as pdf2svg does not always create valid svgs:
inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg

View file

@ -0,0 +1,3 @@
Compiled example
----------------
![Example](linear-functions.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View file

@ -0,0 +1,37 @@
\documentclass[varwidth=false, border=2pt]{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{nicefrac}
\pgfplotsset{every axis legend/.append style={
at={(0,0)},
anchor=north east}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,
axis y line=middle,
grid = major,
width=8cm,
height=8cm,
grid style={dashed, gray!30},
xmin=-5, % start the diagram at this x-coordinate
xmax= 5, % end the diagram at this x-coordinate
ymin=-5, % start the diagram at this y-coordinate
ymax= 5, % end the diagram at this y-coordinate
xlabel=x,
ylabel=y,
legend cell align=left,
legend pos=south east,
legend style={draw=none},
tick align=outside,
enlargelimits=false]
% plot the function
\addplot[domain=-5:5, red, ultra thick,samples=500] {0.5*x};
\addplot[domain=-5:5, green!50!black, ultra thick,dashed,samples=500] {x};
\addplot[domain=-5:5, blue, ultra thick,dotted,samples=500] {2*x};
\legend{$\nicefrac{1}{2} \cdot x$,$x$,$2 \cdot x$}
\end{axis}
\end{tikzpicture}
\end{document}