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.
\usepackage{pgfplots}
\pgfplotsset{width=10cm}    

\begin{figure}
\centering
\begin{tikzpicture}
\makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
\pgfplotsset{axis line on top/.style={
 axis on top=false,
 after end axis/.code={
    \pgfplotsset{axis line style=opaque,
      ticklabel style=opaque,
      tick style=opaque,
      grid=none}
    \pgfplotsdrawaxis}
  }
}
\pgfdeclarehorizontalshading{stefan}{50bp}{
color(0.00000000000000bp)=(violet);
color(8.33333333333333bp)=(blue);
color(16.66666666666670bp)=(cyan);
color(25.00000000000000bp)=(green);
color(33.33333333333330bp)=(yellow);
color(41.66666666666670bp)=(orange);
color(50.00000000000000bp)=(red)
}
\begin{axis}[
%height=9cm,
%width=9cm,
grid=major,
xmajorgrids,
xmin=-0.3,
xmax=0.3,
ymin=0, 
ymax=6,
point meta min={-0.3},
point meta max={0.3},
axis line on top,
%xtick={-0.3,-0.29,...,0.3},
xticklabels={%
$-0.4$,
$-0.3$,
$-0.2$,
$-0.1$,
$\mu$,
$0.1$,
$0.2$,
$0.3$,
$0.4$},
% note: \frac can be done automatically:
% xticklabel style={/pgf/number format/frac},
minor tick num=4,
xlabel=\large$x$,
ylabel=\large$f_{\mu,\sigma^2}(x)$,
colorbar horizontal,colormap/new,no markers,
colormap={new}{color(0cm)=(violet);color(1cm)=(blue);color(2cm)=(cyan);color(3cm)=(green);color(4cm)=(yellow);color(5cm)=(orange);color(6cm)=(red)}]
\addplot gnuplot[shading=stefan,color=black,shader=interp,id=DoG,samples=1000,domain=-0.3:0.3,y domain=0:1]{((1/(sqrt(2*pi*0.00570275999999999)))*exp(-(x-0)**2/(2*0.00570275999999999)))}\closedcycle;
\addplot+ [black] coordinates {(0,0)(0,6)};
\pgfplotsset{tick style={thin,black},every mark/.append style={solid}}
\end{axis}
\begin{axis}[
%height=9cm,
%width=9cm,
xmin=-0.3,
xmax=0.3,
ymin=0, 
ymax=6,
axis line on top,
axis y line*=right,
axis x line=none
]
\pgfplotsset{tick style={thin,black},every mark/.append style={solid}}
\end{axis}
\begin{axis}[
%height=9cm,
%width=9cm,
xmin=-0.3,
xmax=0.3,
ymin=0, 
ymax=6,
axis line on top,
axis x line*=top,
axis y line=none,
xticklabels={%
$-0.4$,
$-0.3$,
$-0.2$,
$-0.1$,
$\mu$,
$0.1$,
$0.2$,
$0.3$,
$0.4$}
]
\pgfplotsset{tick style={thin,black},every mark/.append style={solid}}
\end{axis}
\end{tikzpicture}
\caption{Plot}
\end{figure}

Hi all, I want to remove the black line in this plot how i can make?

share|improve this question
    
Hi, welcome to TeX.sx! Just remove the line \addplot+ [black] coordinates {(0,0)(0,6)}; (but if you didn't want the line, why would you have that plot command in the first place?). –  Jake May 13 '12 at 20:11
    
hello, thanks :), I'm explained bad, I meant the black line which delimits the Gaussian.. –  FormlessCloud May 13 '12 at 21:47
    
Ah, okay, I see. You can pass the option draw=none to the \addplot options for this. I've also simplified your code a bit, see the answer below. –  Jake May 13 '12 at 22:09

1 Answer 1

up vote 7 down vote accepted

For that, you just need to add draw=none to the plot options.

I've made a couple of other improvements to your plot:

Instead of using two more axes to get the tick labels to appear on all sides, you can use extra x ticks and extra y ticks. You can set the ticklabel options for these extra ticks independently of those for the normal ticks, by setting extra x tick style={<options>}.

Instead of using an \addplot for drawing the vertical line, you can use

after end axis/.append code={
    \draw ({rel axis cs:0,0}-|{axis cs:0,0}) -- ({rel axis cs:0,1}-|{axis cs:0,0});
}

which will make sure that the line always spans the entire height of the plot, regardless of the axis limits.

You can change the xticklabels for the colorbar in a way similar to how you can change it for the extra x ticks, using colorbar style={xticklabels={...}}.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{width=10cm}    

\begin{tikzpicture}
\makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
\pgfplotsset{axis line on top/.style={
 axis on top=false,
 after end axis/.append code={
    \pgfplotsset{axis line style=opaque,
      ticklabel style=opaque,
      tick style=opaque,
      grid=none}
    \pgfplotsdrawaxis}
  }
}
\pgfdeclarehorizontalshading{stefan}{50bp}{
color(0.00000000000000bp)=(violet);
color(8.33333333333333bp)=(blue);
color(16.66666666666670bp)=(cyan);
color(25.00000000000000bp)=(green);
color(33.33333333333330bp)=(yellow);
color(41.66666666666670bp)=(orange);
color(50.00000000000000bp)=(red)
}
\begin{axis}[
grid=major,
xmin=-0.3, xmax=0.3,
ymin=0, ymax=6,
point meta min={-0.3},
point meta max={0.3},
axis line on top,
tick style={thin,black},
xticklabel style={text height=1.5ex},
xticklabels={%
$-0.4$,
$-0.3$,
$-0.2$,
$-0.1$,
$\mu$,
$0.1$,
$0.2$,
$0.3$,
$0.4$},
extra x ticks={-0.4,-0.3,...,0.4},
extra x tick labels={%
$-0.4$,
$-0.3$,
$-0.2$,
$-0.1$,
$\mu$,
$0.1$,
$0.2$,
$0.3$,
$0.4$},
extra x tick style={
    xticklabel pos=right,
    xticklabel style={text depth=0pt}
},
extra y ticks={0,...,6},
extra y tick style={
    yticklabel pos=right
},
minor tick num=4,
xlabel=\large $x$,
ylabel=\large $f_{\mu,\sigma^2}(x)$,
colorbar horizontal,
colorbar style={
    xticklabels={%
        $-0.4$,
        $-0.3$,
        $-0.2$,
        $-0.1$,
        $\mu$,
        $0.1$,
        $0.2$,
        $0.3$,
        $0.4$
    },
    xticklabel style={text height=1.5ex}
},
no markers,
colormap={new}{color(0cm)=(violet);color(1cm)=(blue);color(2cm)=(cyan);color(3cm)=(green);color(4cm)=(yellow);color(5cm)=(orange);color(6cm)=(red)},
after end axis/.append code={
    \draw ({rel axis cs:0,0}-|{axis cs:0,0}) -- ({rel axis cs:0,1}-|{axis cs:0,0});
}]
\addplot gnuplot[
    shading=stefan,
    draw=none,
    shader=interp,
    id=DoG,
    samples=1000,
    domain=-0.3:0.3,
    y domain=0:1
]{((1/(sqrt(2*pi*0.00570275999999999)))*exp(-(x-0)**2/(2*0.00570275999999999)))}\closedcycle;
\end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer
    
thank you, perfect! the only thing is that if you look carefully axes are gray now, rather than blacks as I had made ​​myself and the ticks are now under the plot, on the same plain of the grid. I wanted to ask you if you know how to replace the number 0 in the color bar with the letter mu –  FormlessCloud May 14 '12 at 11:39
    
@user14524: I've edited my answer: The tick lines were behind the plot because I used .code instead of .append code, so the axis line on top code was overwritten. –  Jake May 14 '12 at 11:51
    
Perfect ! i have added this code: \pgfplotsset{tick style={thin,black},every mark/.append style={solid}} just before end axis to make ticks black try, and see the difference. is right the way in which is placed? –  FormlessCloud May 14 '12 at 12:47
    
@user14524: Although that placement works, you should just add it to the axis options (I've edited my answer). Also note that the every mark/.append style={solid} doesn't do anything here, since every mark only applies to plot markers (which we're not using here). –  Jake May 14 '12 at 12:51
    
@user14524: If you consider your question answered, please mark it as such by clicking the tick mark next to the answer. Also, consider upvoting by clicking the upward-pointing triangle next to the answer. –  Jake May 14 '12 at 12:56

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.