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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the folowing datapoints obtained from numerical experiments. I have plot these data points using tikz & pgfplots packages. Now I want to show the curvature change of the plots, say the first one (Eta05) from mu=7.5 to 11.5 inside the graph. I use the spy package to do that, but not succeed.

\documentclass{standalone}
\usepackage{tikz,pgfplots,filecontents}
\pgfplotsset{compat=1.11}
\usetikzlibrary{spy}
\begin{filecontents*}{data.csv}
    mu   & Eta05    & Eta1o5    & Eta2o5    & Eta5      & Eta10     & Eta15     & Eta25     
    2.5  & 158.086810 & 148.218338 & 141.185738 & 132.213683 & 123.803119 & 117.787777 & 108.482610 
    3.0  & 98.451835  & 87.054289  & 79.628072  & 72.106007  & 68. 486806 & 67.002723  & 65.169244  
    3.5  & 85.401668  & 74.166957  & 67.125917  & 60.992210  & 59.808002  & 59.948999  & 60.051464  
    4.0  & 80.752934  & 69.614034  & 62.786944  & 57.414396  & 57.387458  & 58.159165  & 58.879482  
    4.5  & 78.649980  & 67.543726  & 60.832928  & 55.909321  & 56.508328  & 57.571088  & 58.532668  
    5.0  & 77.574273  & 66.465392  & 59.817595  & 55.176014  & 56.147092  & 57.360550  & 58.427176  
    5.5  & 76.983310  & 65.852998  & 59.238120  & 54.782912  & 55.991561  & 57.289748  & 58.404536  
    6.0  & 76.644634  & 65.483328  & 58.883928  & 54.557119  & 55.926289  & 57.275203  & 58.412101  
    6.5  & 76.446290  & 65.249637  & 58.655427  & 54.420231  & 55.902972  & 57.283827  & 58.430182  
    7.5  & 76.262599  & 64.992702  & 58.393061  & 54.276059  & 55.905690  & 57.321824  & 58.471161  
    8.5  & 76.208315  & 64.869417  & 58.255500  & 54.208693  & 55.927382  & 57.360911  & 58.506102  
    9.5  & 76.204858  & 64.804256  & 58.173757  & 54.172047  & 55.949867  & 57.393085  & 58.532877  
    10.0 & 76.211650  & 64.783063  & 58.144280  & 54.159353  & 55.959829  & 57.406375  & 58.543584  
    11.5 & 76.244573  & 64.742614  & 58.080603  & 54.132025  & 55.983407  & 57.436788  & 58.567443  
    13.5 & 76.292395  & 64.713241  & 58.025281  & 54.106536  & 56.002348  & 57.461302  & 58.586027  
    15   & 76.323304  & 64.698158  & 57.994336  & 54.090627  & 56.010017  & 57.472000  & 58.593899  
    20   & 76.391403  & 64.660545  & 57.919966  & 54.046219  & 56.015134  & 57.484401  & 58.602444  
    25   & 76.424631  & 64.630563  & 57.868278  & 54.010977  & 56.008094  & 57.482538  & 58.600464  
    30   & 76.440877  & 64.605689  & 57.829598  & 53.982983  & 55.998462  & 57.476841  & 58.595800  
    40   & 76.452460  & 64.568135  & 57.776076  & 53.942674  & 55.980506  & 57.464379  & 58.585989  
    50   & 76.454123  & 64.542162  & 57.741491  & 53.915912  & 55.966629  & 57.454055  & 58.577986 
\end{filecontents*}
\pgfplotstableread[col sep=&]{data.csv}{\mytable}
\begin{document}
    \begin{tikzpicture}
    %\pgfplotsset{every axis/.append style={line width=1pt}}
    \begin{axis}[
    xmin=0, xmax=50,
    ymin=50, ymax=165,
    ]
    \addplot[color=magenta,mark=o,mark color=green] table[y = Eta05] from \mytable ;
\addplot[color=teal,mark=square,mark color=green] table[y = Eta1o5] from \mytable ; 
\addplot[color=green,mark=*,mark color=green] table[y = Eta2o5] from \mytable ; 
\addplot[color=blue,mark=star,mark color=green] table[y = Eta5] from \mytable ; 
\addplot[color=cyan,mark=otimes,mark color=green] table[y = Eta10] from \mytable ; 
\addplot[color=red,mark=triangle,mark color=green] table[y = Eta15] from \mytable ; 
\addplot[color=orange,mark=x,mark color=green] table[y = Eta25] from \mytable ;  
\coordinate (spypoint) at (8,76);
\coordinate (magnifyglass) at (8,89); 
\end{axis}
\spy [blue, size=2.5cm] on (spypoint)
in node[fill=white] at (magnifyglass);
    \end{tikzpicture}
\end{document}

This is my desirable output. enter image description here

share|improve this question

You can place a coordinate within the axis and refer to it from outside.

\begin{tikzpicture}[spy using outlines={circle, magnification=3, size=2.5cm, connect spies}]
\begin{axis}[ymax=110,no marks]
\pgfplotsinvokeforeach{05,1o5,5,10,15,25}{
\addplot+[mark=o] table[x=mu,y=Eta#1] \mytable;
}
\coordinate (a) at (axis cs:8.5,76);
\end{axis}
\spy [red] on (a)in node  at (4,4);
\end{tikzpicture}

enter image description here

share|improve this answer
    
Could you please show all the plots with this magnification? Using the above code I didn't get the desired result. – Litun John Feb 29 at 10:56
    
@LitunJohn What is the desired result? – percusse Feb 29 at 11:01
    
I have added my desired result in the updated question. – Litun John Feb 29 at 11:38
    
@LitunJohn That dip is not present in your data. – percusse Feb 29 at 13:01
    
This is the data in column 1 7.5 & 76.262599, 8.5 & 76.208315, 9.5 & 76.204858,10.0 & 76.211650 , 11.5 & 76.244573, which is clearly a dip. – Litun John Feb 29 at 15:32

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.