decimal separator and centering with Tikz
The following code creates a figure with Tikz without the use of pfgplots (that I want to avoid here):
% compilation: pdflatex --jobname=Runge-f1 Runge.tex
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage{tikz}
\pgfrealjobname{Runge}
\begin{filecontents}{B6.dat}
-1 0
0 5
1 0
\end{filecontents}
\definecolor{rouge}{RGB}{233,55,77}
\def\xmin{-1.1}\def\xmax{1.1}\def\ymin{-.6}\def\ymax{5.6}
\begin{document}
\beginpgfgraphicnamed{Runge-f1}%
\footnotesize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}[>=latex,scale=1.4,x=4cm,y=1cm]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% background
\fill[rouge!10] (\xmin,\ymin) rectangle (\xmax,\ymax);
%%%% grid and labels
\begin{scope}
\clip (\xmin,\ymin) rectangle (\xmax,\ymax);
\foreach \x in {-1,-0.75,...,1} \draw[rouge!35] (\x,\ymin) -- (\x,\ymax);
\foreach \x in {-1,-0.75,...,1} \node[fill=rouge!10,inner sep=2pt,anchor=south,font=\tiny\color{rouge}] at (\x,-.5){$\mathsf\x$}; %%%%%% loop 1
\end{scope}
%%%% curve
\draw plot file{B6.dat};
%%%% external frame
\draw[line width=.6pt,rouge!50] (\xmin,\ymin) rectangle (\xmax,\ymax);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\endpgfgraphicnamed%
\end{document}
how is it possible to have a comma as the decimal separator in loop 1?
in loop 1, would it be possible to center the $\x$ labels with respect to the grid by ignoring the negative sign '-' when present?
The following code creates a figure with Tikz without the use of pfgplots (that I want to avoid here):
% compilation: pdflatex --jobname=Runge-f1 Runge.tex
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage{tikz}
\pgfrealjobname{Runge}
\begin{filecontents}{B6.dat}
-1 0
0 5
1 0
\end{filecontents}
\definecolor{rouge}{RGB}{233,55,77}
\def\xmin{-1.1}\def\xmax{1.1}\def\ymin{-.6}\def\ymax{5.6}
\begin{document}
\beginpgfgraphicnamed{Runge-f1}%
\footnotesize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}[>=latex,scale=1.4,x=4cm,y=1cm]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% background
\fill[rouge!10] (\xmin,\ymin) rectangle (\xmax,\ymax);
%%%% grid and labels
\begin{scope}
\clip (\xmin,\ymin) rectangle (\xmax,\ymax);
\foreach \x in {-1,-0.75,...,1} \draw[rouge!35] (\x,\ymin) -- (\x,\ymax);
\foreach \x in {-1,-0.75,...,1} \node[fill=rouge!10,inner sep=2pt,anchor=south,font=\tiny\color{rouge}] at (\x,-.5){$\mathsf\x$}; %%%%%% loop 1
\end{scope}
%%%% curve
\draw plot file{B6.dat};
%%%% external frame
\draw[line width=.6pt,rouge!50] (\xmin,\ymin) rectangle (\xmax,\ymax);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\endpgfgraphicnamed%
\end{document}
how is it possible to have a comma as the decimal separator in loop 1?
in loop 1, would it be possible to center the $\x$ labels with respect to the grid by ignoring the negative sign '-' when present?
No comments:
Post a Comment