2

I have the following two TikZ pictures (see code at bottom). How can I achieve that the style of the axes in the second picture (the function plot) is the same as in the first picture?

\documentclass{amsart}

\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgffor}

\begin{document}

\begin{tikzpicture}[scale=1] 
\draw[->] (-0.3,0) -- (7,0);
\draw (8,0) node[below] {$\gamma$};
\draw[->] (0,-0.3) -- (0,5) node[left] {$b_{1+\gamma}$};
\draw (2,.1) -- (2,-.1) node[below] {$p(\rho)-1$};
\draw[dashed] (2,0) -- (2,1.8);
\draw[dashed] (0,2) -- (2,2);
\draw (-.1,2) -- (.1,2) node[left] {$b_\#(\rho)\;$};
\draw (6,.1) -- (6,-.1) node[below] {$1$};
\draw (-0.1,1) -- (0.1,1) node[left] {$b_2\;$};
\draw (0,3.5) .. controls (2,1.8) and (3,1.2) .. (6,1);
\draw[dashed] (0,1) -- (6,1);
\fill[color=white] (0,3.5) circle (3pt);
\draw[color=black] (0,3.5) circle (3pt);
\fill[color=black] (0,4.3) circle (3pt) node[left] {$b_\ast$};
\end{tikzpicture}

\medskip

\begin{tikzpicture}
  \begin{axis}[domain = 0:1, samples = 100]
    \addplot[color = black]  {pi/(((pi/2)+atan(x/sqrt(1-x^2))*pi/180)};
  \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

1 Answer 1

2

Add axis lines=center to the axis options. You can also add axis line style={shorten >=-10pt, shorten <=-10pt} to make the axes go a bit further (by 10pt), so the plot doesn't touch the arrow tips.

In order to change the arrow tips, you can load arrows.meta and then add -{>} for a simple arrow tip.

Output

example image

Code

\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgffor}

\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[domain=0:1,samples = 100, axis lines=center, axis line style={shorten >=-10pt, shorten <=-10pt,-{>}}, ymin=0.6,ytick={0.8,1,...,2}]
    \addplot[color = black]  {pi/(((pi/2)+atan(x/sqrt(1-x^2))*pi/180)};
  \end{axis}
\end{tikzpicture}
\end{document}
14
  • Great, thx! Is it also possible to let the y axis start at y=0.8, say? Also the style of the arrow at the tip of the axes is a bit different from the other picture ...
    – lpdbw
    Commented Dec 9, 2015 at 14:16
  • 1
    @lpdbw See new edit. Is that what you had in mind?
    – Alenanno
    Commented Dec 9, 2015 at 14:36
  • 1
    @lpdbw This library has been available for a long time now, how long ago have you updated your packages? Load your Tex Utility and update the packages. It might take a while depending on how many there are to update. Alternatively, you can comment out the library command, and replace the arrow tip option with a simple ->. It will still work, because it's still "backwards" supported.
    – Alenanno
    Commented Dec 9, 2015 at 14:48
  • 1
    @lpdbw Add \listfiles to your preamble, then compile. Open the file named <yourfilename>.log and check the tikz.sty version. It should say 2015/08/07 v3.0.1a (rcs-revision 1.151). Also pgf.sty should be almost the same line except the revision will be 1.15.
    – Alenanno
    Commented Dec 9, 2015 at 14:56
  • 1
    @lpdbw Try, x label style={at={(axis description cs:1,-0.1)},anchor=north west}, y label style={at={(axis description cs:-0.1,1)},anchor=south east}, and fix accordingly. :)
    – Alenanno
    Commented Dec 9, 2015 at 16:04

You must log in to answer this question.

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