I am working on putting nice figures into latex from Matlab using tikz. The problem I am having is that I have a graph written on tikz (a set of continuous points of a density function) I have two vertical lines truncating this distribution. As
enter image description here

What I would like to do is to add a shade between those two vertical lines and I would also like to give labeling to those points on the x-axis I tried doing this

\node [blue] at (2,0) {$\circ$};
\addplot[thick, samples=50, smooth,domain=0:6,magenta, name path=three] coordinates {(2,-1)(2,3)};
\node [red] at (3,0.1) {\textbullet};

Both of which had failed

  • Can you complete your example to a full MWE? Just the code necessary to create the image above. – Alenanno May 15 '16 at 15:29

Stealing Adapting liberally from Jake's answer to Plotting bell shaped curve in TikZ-PGF, and not knowing what sort of curve you had:

enter image description here



  no markers, domain=-5:5, samples=100,
  axis lines*=left, xlabel=$x$, ylabel=$y$,
  every axis y label/.style={at=(current axis.above origin),anchor=south},
  every axis x label/.style={at=(current axis.right of origin),anchor=west},
  height=5cm, width=12cm,
  xtick={0,2}, ytick=\empty,
  enlargelimits=false, clip=false, axis on top,
  grid = major
  \addplot [fill=cyan!20, draw=none, domain=0:2] {gauss(0,1)} \closedcycle;
  \addplot [very thick,cyan!50!black] {gauss(0,1)};

\draw [yshift=-0.6cm, latex-latex](axis cs:0,0) -- node [fill=white] {$a$} (axis cs:0,0);
\draw [yshift=-0.6cm, latex-latex](axis cs:2,0) -- node [fill=white] {$b$} (axis cs:2,0);

|improve this answer|||||
  • Thank you very much. But what if the plot was not a normal distribution ? like say a stable distribution density – rsc05 May 15 '16 at 14:57
  • Do you have a function for it, or just data? If there's a function, use the \gauss function in the example as a guide for making your own. If data, I'll have to look further. – Mike Renfro May 15 '16 at 14:58
  • I just have data, the function is done in matlab (It is a long code) – rsc05 May 15 '16 at 15:01

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.