1

I have this semilogarithmic scale in Latex:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}  
\begin{semilogxaxis}[xmin=1, xmax=1e5, domain=1:1e5]
\addplot {(1/(2*pi*x*0.000001))/((sqrt((39.33)^2+(1/(2*pi*x*0.000001))^2))};
\end{semilogxaxis}
\end{tikzpicture}
\end{document}

enter image description here

I need that x-grid will be, for example:

5*10^-2-----5*10^-1-----5*10^0-----5*10^1-----5*10^2.

0
1

Here is one possible way.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}% <- change if you have an older version
\begin{document}
\begin{tikzpicture}  
\begin{semilogxaxis}[xmin=1, xmax=1e5, domain=1:1e5,
xtick={2,20,200,2000,2e4},xticklabel={$\ifnum\ticknum=0
2
\else
2\cdot 10^{\ticknum}
\fi$}]
\addplot {(1/(2*pi*x*0.000001))/((sqrt((39.33)^2+(1/(2*pi*x*0.000001))^2))};
% cross check
% \path (axis cs:200,0) node[circle,draw]{};
\end{semilogxaxis}
\end{tikzpicture}
\end{document}

enter image description here

Or, as for the question in the comments:

\documentclass[border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17,% <- change if you have an older version
width=12cm}
\begin{document}
\begin{tikzpicture}  
\begin{semilogxaxis}[xmin=1e-2, xmax=1e5, domain=1e-2:1e5,
xtick={2e-2,2e-1,2,20,200,2000,2e4},xticklabel={$\ifnum\the\numexpr\ticknum-2=0
2
\else
2\cdot 10^{\the\numexpr\ticknum-2}
\fi$}]
\addplot {(1/(2*pi*x*0.000001))/((sqrt((39.33)^2+(1/(2*pi*x*0.000001))^2))};
\end{semilogxaxis}
\end{tikzpicture}
\end{document}

enter image description here

How does one come up with things of this sort? Assuming you find the pgfplots manual too overwhelming, you may follow this strategy: perform a Google picture search (or a plain Google search) for

  site:tex.stackexchange.com <search term(s)>

and check what others do. In theory the votes of the posts should indicate how good the post is (but in practice the votes are influenced by many factors beyond the quality of the post). This may give you are starting point. Oftentimes, in particular with more practice, you will be able to solve your problem. If not, you have a nice starting point for a question that will be better received than an "empty" question, also because your own attempts help to make the question clearer.

2
  • I didn't know. I'm sorry... Thanks for the answer! But, how can i do that the graph start on 2.10^-2 ... 2.10^-1? Could you recommend a manual that deals with this topic and general graphics? Again, Thank you so much!!! Apr 14 '20 at 14:52
  • @MatiasTevez I added such an example.
    – user194703
    Apr 14 '20 at 19:50

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.