3

I am a beginner with TikZ and have two problems by plotting a function.

first: The function is quite big, I need 8000 points in x direction and 50 in y. Every time I try to get some similar big aces they are too big. I tried to scale them but it did not work.

second: The function is: f(x)=10ln(1+1/(4pi^24pi0,025^2/4pi*(340/x)) I tried to plot this function up to 8 points in x direction but I only get an error.

Can some one help me or send me a similar question where I can find a solution?

Thanks

1
  • Welcome to TeX.SE! (i) do you really need to draw all 8000 points? So many if points cant be placed in typical diagram without overlapping them. Try to filter them and draw only each 100th point. (ii) it is not clear what is the problem. Clarify it with small, compilable document, which reproduce your problem.
    – Zarko
    Mar 11 '21 at 23:00
4

pgfplots scales the plot to some desired width and height. If you plot a large number of samples, it can make sense to simplify the expression by cancelling common factors in fractions etc.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=10cm,height=7cm,
    xlabel={$x$},ylabel={$f(x)$}]
 \addplot[domain=1:8000, smooth, samples=501]
    {10*ln(1+1/(0.01*pi^2/4*(340/x))}; 
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

4

If I understand you correctly, the problem is that when drawing functions with TikZ, the default unit of length is 1cm, and you want to keep the 1:1 correspondence between TikZ coordinates and (x, y) values for your function?

If so, it may be enough to change TikZ's unit vectors; see section 25.2 of the TikZ documentation:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=0.04pt,y=4pt]
\draw[domain=1:8000, smooth, samples=250] plot (\x,{10*ln(1+1/(4*pi^2*4*pi*0.025^2/4*pi*(340/\x)))});
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.