% !TEX TS-program=pdflatex
% !TEX encoding=UTF-8 Unicode
%
% File name: linearGraphTypes1.tex
% Description:
% Linear Functions Graph
%
% Composer: private course and tutor course
\documentclass[12pt,a4paper]{report}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{bm}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{0.25pt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\pgfplotsset{%
axis line origin/.style args={#1,#2}{
x filter/.append code={ % Check for empty or filtered out numbers
\ifx\pgfmathresult\empty\else\pgfmathparse{\pgfmathresult-#1}\fi
},
y filter/.append code={
\ifx\pgfmathresult\empty\else\pgfmathparse{\pgfmathresult-#2}\fi
},
xticklabel=\pgfmathparse{\tick+#1}\pgfmathprintnumber{\pgfmathresult},
yticklabel=\pgfmathparse{\tick+#2}\pgfmathprintnumber{\pgfmathresult}
}
}
\makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
\pgfplotsset{
every tick/.append style={color=black},
after end axis/.append code={
\pgfplotsset{
axis line style=opaque,
ticklabel style=opaque,
tick style=opaque,
grid=none
}
\pgfplotsdrawaxis
},
} % applies to major and minor ticks,
\begin{document}
\begin{tikzpicture}[scale=1]
\begin{axis}[x=1cm,y=1cm,
axis lines = middle,
xlabel = {$\mathbf{x\ axis}$},
ylabel = {$\mathbf{y\ axis}$},
xtick = \empty,
ytick = \empty,
xmin=-3, xmax=3.5,
ymin=-3, ymax=3.5,small, axis on top, grid=none, minor grid style={very thin,gray!30}, major grid style={very thin,gray!30},
%% Draw the origin:
after end axis/.code={
\path (axis cs:0,0)
node [anchor=north east,yshift=-0.075cm] {0};
} ]
% Plot 1, type of slope: zero slope, y = constant, type of line: horizontal
\addplot [
domain = -1:5,
samples = 1000,blue,very thick] coordinates {(-3,1.5)(3,1.5)}
node [pos=.75, above, black] {\bfseries $\mathbf{y=b=f(x)}$};
\end{axis}
\end{tikzpicture}
\end{document}
2. Save file as linearGraphTypes1.tex3. Then build or typeset the Latex code.
Tidak ada komentar:
Posting Komentar