8

I'm trying to plot a function, but with the x-axis logarithmic. I use PSTricks and the package pstricks-addwith the algebraic option, to write my function litterally. My function to be plotted is : Function to be plotted

I want to have the X-axis logarithmic, from 10^-1 to 10^2... But I can't figure how to do it...

Here's what I tried...

\psset{xunit=2,yunit=6, algebraic}
\begin{pspicture}[showgrid=false](0,0)(2,1)
   \psaxes[xlogBase=10, comma,subticks=5,
            arrowscale=1.5]{->}(3,0.8)[Voltage (V),-90][Yield (\%),90]
   \psplot[linecolor=red]{0.01}{2}{(x/(1+(1+x^2)^0.5))^2}
\end{pspicture}

That generates this : The Code What I want to have is this : My Objectif

Does I have to adapt the function so that it fits the non-logarithmic grid once plotted ? I don't understand the principe of plotting a log function in a non-log grid...

If you could also explain me that it would be great.

2 Answers 2

7

enter image description here Here is a solution for PSTricks.

\documentclass[pstricks,border=10pt]{standalone}

\usepackage{pst-plot,pstricks-add}

\begin{document}

\psset{xunit=2,yunit=6,plotpoints=500,algebraic=true,linewidth=0.5pt,dash=2pt 2pt}

\begin{pspicture}(-1.4,-0.2)(3.9,1.2)
  \psaxes[axesstyle=frame,xlogBase=10,comma,logLines=x,dy=0.2,Dy=20,xsubticks=9,
   yticksize=0 4,subticklinestyle=dashed,ticklinestyle=dashed,Ox={-1}](-1,0)(3,1.0)[Voltage (V),0][Yield (\%),90]
   \psplot[linecolor=red]{-1}{3}{10^x^2/(1+sqrt(1+10^x^2))^2}
\end{pspicture}

\end{document}
3
  • 1
    So the trick is to manually transform the function by replacing x with 10^x, correct?
    – Jake
    May 26, 2014 at 17:54
  • Yes indeed ! I'll remember it for the next time ;) Thanks again !
    – 3isenHeim
    May 26, 2014 at 17:58
  • I am sorry. Your signature name (i.e., Thomas, probably Thomas Söll) is no longer needed in the contents as the user profile link has been automatically attached to the bottom right corner of the post. May 26, 2014 at 18:06
8

Here's how you would do this with PGFPlots:

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.10}

\begin{document}
\begin{tikzpicture}%
  \begin{axis}[%
    xmode = log, % X axis is logarithmic
    domain = 1e-1:1e2, % Domain over which the function is evaluated
    ymax = 100, % Explicitly set the upper limit of the Y axis (the others are automatically determined)
    enlargelimits = false, % Don't add padding
    ylabel = Yield / \%, % Set the labels
    xlabel = Voltage / V,
    grid = both % Draw grid lines for the X and Y axis
  ]
  \addplot [very thick, smooth] { 100 * x^2 / (1 + sqrt(1+x^2))^2};
  \end{axis}
\end{tikzpicture}%
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .