Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using pgfplots to plot the a function. I have been looking around on the forums, but I could not find a solution. I would like to origin to be indicated as a 0 on the x axis. I would also like to get the axis labels to appear respectively left and below the axis. Any ideas?

I have the following plot:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[width=7cm, height=2cm,xmin=-6,xmax=6,ymin=0,ymax=1,
no markers,
samples=50,
axis lines=left, 
axis lines=middle, 
scale only axis,
% extra y ticks={0.5},
/pgfplots/ytick={0, 0.5,1}, % make steps of length 0.5
/pgfplots/xtick={-5,0,5}, % make steps of length 5
    xlabel=$Li$,
    ylabel={$f_{comp}(Li))$}
  ] 
    \addplot {1/(1+exp(-x)}; 
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this question
2  
Welcome to TeX.sx! I expanded the code to a full working code example and added a picture of the output. –  Benedikt Bauer Oct 23 '12 at 10:20
    
Thanks for adding the picture and expanding the code! –  dorien Oct 23 '12 at 11:44

1 Answer 1

up vote 7 down vote accepted

The middle option for the axis lines assumes that the axis lines intersect, so the 0 ticks aren't shown. If you use axis y line=middle, axis x line=bottom instead of axis lines=middle, you get the desired tick mark:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    width=7cm, height=2cm,xmin=-6,xmax=6,ymin=0,ymax=1,
    no markers,
    samples=50,
    axis y line=middle, 
    axis x line=bottom,
    scale only axis,
    ytick={0, 0.5,1}, % make steps of length 0.5
    xtick={-5,0,5}, % make steps of length 5
    xlabel=$Li$,
    ylabel={$f_{comp}(Li))$}
  ] 
    \addplot {1/(1+exp(-x)}; 
  \end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
1  
Thanks! Combined withevery axis x label/.style={at={(current axis.right of origin)},anchor=north west}, every axis y label/.style={at={(current axis.above origin)},anchor=north east},... I got a perfect result! –  dorien Oct 23 '12 at 13:23
    
What could I do, if I wanted to keep both axes as middle (so they intersect) and print the zero labels on top of them? Would that be possible? –  sdaau Feb 15 at 21:39
1  
@sdaau: Take a look at tex.stackexchange.com/a/39099/2552 –  Jake Feb 15 at 21:48
    
Many, many thanks for that, @Jake - that answers it completely! Cheers! –  sdaau Feb 15 at 21:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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