Math & ScienceAxis lettering

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
guest4

Axis lettering

Post by guest4 »

Hey guys,

I am quite new to Latex and I like to do a graphic on my own with TikZ.
The graphics should look more or lesse the same as this:

https://www.energie-lexikon.info/img/ph ... erung1.png

I am currently almost done, but what I miss is the axis lettering which I have no clue to realize. I read through different documentations but nothing works that well.
Can you help me with it?

Second, I like to know if my code is good for what I like to do. Or can I improve it or do it better in less code?

Code: Select all

\documentclass[parskip=full]{scrbook} 
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage[autostyle=true,german=quotes]{csquotes} 
\usepackage[ngerman]{babel} 
\usepackage{lmodern} 
\usepackage{booktabs} 
\usepackage{marvosym} 
\usepackage{float} 
\usepackage{caption} 
\usepackage{graphicx} 
\usepackage{tikz} 
\usepackage{gensymb} 
\usepackage{todonotes} 
\usepackage{amsmath, amsfonts, amssymb} 
\usepackage[per-mode=fraction, decimalsymbol=comma]{siunitx} 
\usepackage{babelbib} 
\usepackage{textcomp} 
\usepackage[hidelinks]{hyperref} 


\begin{document} 
    
   \begin{tikzpicture}[domain=0:14] 
      \draw[step=1, gray, very thin, loosely dotted] (0,-2.5) grid (14,2.5); 
      \draw[->, thick] (-0.2,0) -- (14.3,0) node[right] {$t$}; 
      \draw[->, thick] (0,-2.6) -- (0,2.6) node[above] {$V(t)$}; 
    
      \draw [color=black, samples=300, dashed] plot (\x, {2*sin(\x r}); 
    
      \begin{scope}[color=red, samples=10, very thick] 
         \draw [domain=2.3:3.1415] plot (\x, {2*sin(\x r}); 
         \draw [domain=5.441:6.2841] plot (\x, {2*sin(\x r}); 
         \draw [domain=8.583:9.4247] plot (\x, {2*sin(\x r}); 
         \draw [domain=11.7247:12.566] plot (\x, {2*sin(\x r}); 
      \end{scope} 
    
    
      \begin{scope}[color=red, very thick] 
         \draw (0,0)--(2.3,0); 
         \draw (2.3,0)--(2.3,1.4914); 
         \draw (5.441,0)--(5.441,-1.4914); 
         \draw (3.1415,0)--(5.441,0); 
         \draw (8.583,0)--(8.583,1.4914); 
         \draw (6.2841,0)--(8.583,0); 
         \draw (11.7247,0)--(11.7247,-1.4914); 
         \draw (9.4247,0)--(11.7247,0); 
         \draw (12.566,0)--(14,0); 
         \end{scope}   
      \end{tikzpicture}   
    
\end{document} 
 

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Axis lettering

Post by Stefan Kottwitz »

I guess this has already been solved here at goLaTeX.de.

If not, let us know.

Suggestion of Elke is:

Code: Select all

\documentclass[parskip=full]{scrbook} 

\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage[ngerman]{babel} 
\usepackage{lmodern} 
\usepackage{pgfplots} 
\pgfplotsset{compat=1.12} 

\begin{document} 

\begin{tikzpicture} 
  \begin{axis}[ 
    x=1cm,y=1cm, 
    xlabel=$t$,ylabel=$V(t)$, 
    domain=0:14,xmin=0,xmax=14, 
    ytick={-2,...,2}, 
    grid=major, 
    grid style=dashed 
  ] 
    \addplot[dashed,thick,samples=100] {2*sin(deg(x))}; 
    \draw(current axis.left of origin)--(current axis.right of origin); 
    \draw [red,thick, samples = 50, very thick] 
      (0,0) foreach \n in {1,...,4} { 
         -- (\n*pi-pi/4,0) -- plot [domain=\n*pi-pi/4:\n*pi] (\x, {2*sin(\x r}) 
      }--(14,0); 
  \end{axis} 
\end{tikzpicture} 
\end{document}
plot.png
plot.png (10.86 KiB) Viewed 4335 times
Stefan
LaTeX.org admin
Post Reply