5

I'm sorry for not providing code for my question, as I usually always provide code but this time I am not really sure how to achieve my goal, which is why I would like your guy's help. So I am trying to plot the phase Portrait of a van der pol oscillator. The way I wish the plot to look is this way: enter image description here

I am trying to emphasize the attraction region. My problem is the followong:

1) I am not familiar with quiver and also not sure how to use it

2) I can get the data from Matlab but I do not know how to use it

A code example of how this can be achieved would of course be perfect but tips on how to use tikz in combination with Matlab would also be okay. Till now I exported a data set with the command stated in pgfplots with 4 columns (x,y,u,v) but I am not really sure how to use them. Is there a way to make pgf use the ready data ?

I appreciate all the help

   5.0000000e+00   5.0000000e+00   1.5375045e-02  -3.8620859e-01
   5.0153750e+00   4.6137914e+00   3.4876123e-02  -8.9247723e-01
   5.0697522e+00   3.2150455e+00   4.7120884e-02  -1.2339311e+00
   5.1096168e+00   2.1459291e+00   3.2612691e-02  -8.9119732e-01
   5.1349776e+00   1.4326509e+00   2.0692523e-02  -5.9536377e-01
   5.1510019e+00   9.5520159e-01   1.3088303e-02  -4.0194104e-01
   5.1611542e+00   6.2876881e-01   8.2438303e-03  -2.7656489e-01
   5.1674895e+00   4.0207181e-01   5.0626974e-03  -1.9276422e-01
   5.1712796e+00   2.4324037e-01   2.9348841e-03  -1.3523094e-01
   5.1733593e+00   1.3160992e-01   1.5130955e-03  -9.4896595e-02
   5.1743058e+00   5.3447176e-02   5.8677480e-04  -6.1018779e-02
   5.1745328e+00   9.5723602e-03   8.0115214e-05  -4.0088716e-02
   5.1744660e+00  -2.6730257e-02  -1.5404170e-04  -3.0781832e-02
   5.1742248e+00  -5.1991305e-02  -3.8495104e-04  -2.6463713e-02
   5.1736961e+00  -7.9657682e-02  -7.2776314e-04  -2.7461272e-02
   5.1727692e+00  -1.0691385e-01  -1.1781516e-03  -2.6064072e-02
   5.1713398e+00  -1.3178583e-01  -1.7339165e-03  -2.3080854e-02
   5.1693014e+00  -1.5307556e-01  -2.4070299e-03  -1.9218339e-02
   5.1665258e+00  -1.7022250e-01  -3.2386956e-03  -1.5049417e-02
   5.1628240e+00  -1.8317439e-01  -4.3388471e-03  -1.1024378e-02
   5.1578481e+00  -1.9227126e-01  -6.0468154e-03  -7.5010259e-03
   5.1507304e+00  -1.9817644e-01  -8.1222890e-03  -4.3633595e-03
   5.1416035e+00  -2.0099798e-01  -9.1715588e-03  -1.9070612e-03
   5.1323873e+00  -2.0199056e-01  -1.3417789e-02  -1.0268839e-03
   5.1147679e+00  -2.0305175e-01  -1.7661691e-02  -8.2170241e-04
   5.0970639e+00  -2.0363397e-01  -2.2391117e-02  -9.9109217e-04
   5.0699857e+00  -2.0503393e-01  -2.3287887e-02  -9.7531501e-04
   5.0504881e+00  -2.0558460e-01  -1.9527635e-02  -8.1399390e-04
   5.0309304e+00  -2.0666192e-01  -2.3042819e-02  -9.7717744e-04
   5.0044025e+00  -2.0753895e-01  -2.3418200e-02  -1.0761901e-03
   4.9840940e+00  -2.0881430e-01  -2.0366409e-02  -9.6606661e-04
   4.9636696e+00  -2.0947109e-01  -2.3082076e-02  -1.0687046e-03
   4.9379299e+00  -2.1095171e-01  -2.6011741e-02  -1.0815549e-03
   4.9116462e+00  -2.1163420e-01  -2.4149461e-02  -1.1651869e-03
   4.8896310e+00  -2.1328208e-01  -2.1354325e-02  -1.0932455e-03
   4.8689375e+00  -2.1382069e-01  -2.2031356e-02  -9.8070964e-04
   4.8455682e+00  -2.1524350e-01  -2.5224340e-02  -1.1723750e-03
   4.8184888e+00  -2.1616544e-01  -2.6552952e-02  -1.3619678e-03
   4.7924623e+00  -2.1796744e-01  -2.4875557e-02  -1.2204887e-03
   4.7687377e+00  -2.1860641e-01  -2.3647924e-02  -1.1125943e-03
   4.7451665e+00  -2.2019263e-01  -2.4990119e-02  -1.2789247e-03
   4.7187575e+00  -2.2116426e-01  -2.7204798e-02  -1.4193725e-03
   4.6907569e+00  -2.2303137e-01  -2.7720404e-02  -1.3878697e-03
   4.6633167e+00  -2.2394000e-01  -2.6718927e-02  -1.3822717e-03
   4.6373190e+00  -2.2579592e-01  -2.6499987e-02  -1.4375387e-03
   4.6103167e+00  -2.2681508e-01  -2.7907499e-02  -1.4895473e-03
   4.5815040e+00  -2.2877501e-01  -2.9544655e-02  -1.5751089e-03
   4.5512274e+00  -2.2996530e-01  -2.9815198e-02  -1.6623333e-03
   4.5218736e+00  -2.3209968e-01  -2.9370497e-02  -1.6568117e-03
   4.4924864e+00  -2.3327892e-01  -2.9796693e-02  -1.6701997e-03
   4.4622803e+00  -2.3544008e-01  -3.1298785e-02  -1.7978494e-03
   4.4298888e+00  -2.3687462e-01  -3.2502356e-02  -1.9229918e-03
   4.3972755e+00  -2.3928606e-01  -3.2808898e-02  -1.9458717e-03
   4.3642710e+00  -2.4076636e-01  -3.2973966e-02  -1.9846557e-03
   4.3313276e+00  -2.4325537e-01  -3.3929627e-02  -2.0981889e-03
   4.2964118e+00  -2.4496274e-01  -3.5330052e-02  -2.2230522e-03
   4.2606675e+00  -2.4770148e-01  -3.6500550e-02  -2.3201369e-03
   4.2234107e+00  -2.4960302e-01  -3.7109322e-02  -2.4210438e-03
   4.1864489e+00  -2.5254356e-01  -3.7866850e-02  -2.5258135e-03
   4.1476770e+00  -2.5465464e-01  -3.9130255e-02  -2.6549304e-03
   4.1081884e+00  -2.5785342e-01  -4.0829064e-02  -2.8266337e-03
   4.0660188e+00  -2.6030791e-01  -4.2127466e-02  -3.0008646e-03
   4.0239334e+00  -2.6385515e-01  -4.3290003e-02  -3.1505155e-03
   3.9794388e+00  -2.6660894e-01  -4.4613726e-02  -3.3248984e-03
   3.9347060e+00  -2.7050495e-01  -4.6660425e-02  -3.5725176e-03
   3.8861180e+00  -2.7375398e-01  -4.8596167e-02  -3.8338285e-03
   3.8375136e+00  -2.7817261e-01  -5.0694549e-02  -4.1079148e-03
   3.7847289e+00  -2.8196981e-01  -5.2563008e-02  -4.3978063e-03
   3.7323876e+00  -2.8696822e-01  -5.5288920e-02  -4.7822653e-03
   3.6741511e+00  -2.9153434e-01  -5.7922409e-02  -5.1901599e-03
   3.6165428e+00  -2.9734854e-01  -6.1603931e-02  -5.7265594e-03
   3.5509432e+00  -3.0298746e-01  -6.4589583e-02  -6.2588600e-03
   3.4873636e+00  -3.0986626e-01  -6.9210468e-02  -7.0094933e-03
   3.4125223e+00  -3.1700644e-01  -7.3036226e-02  -7.7519262e-03
   3.3412912e+00  -3.2537011e-01  -8.0258291e-02  -8.9849554e-03
   3.2520057e+00  -3.3497635e-01  -8.5032194e-02  -1.0080538e-02
   3.1712268e+00  -3.4553119e-01  -9.5834397e-02  -1.2154307e-02
   3.0603369e+00  -3.5928497e-01  -1.0165388e-01  -1.3825426e-02
   2.9679190e+00  -3.7318204e-01  -9.5628158e-02  -1.4342106e-02
   2.8690806e+00  -3.8796918e-01  -1.0089907e-01  -1.5993383e-02
   2.7661209e+00  -4.0516881e-01  -1.3008578e-01  -2.2923141e-02
   2.6089090e+00  -4.3381546e-01  -1.4845392e-01  -2.9258572e-02
   2.4692130e+00  -4.6368595e-01  -1.5682481e-01  -3.5970836e-02
   2.2952594e+00  -5.0575713e-01  -1.7213529e-01  -4.5530553e-02
   2.1249425e+00  -5.5474706e-01  -1.8138057e-01  -5.7431808e-02
   1.9324982e+00  -6.2062075e-01  -2.0120486e-01  -7.6809066e-02
   1.7225327e+00  -7.0836519e-01  -2.1977012e-01  -1.0325325e-01
   1.4929580e+00  -8.2712725e-01  -2.3855726e-01  -1.3888518e-01
   1.2454182e+00  -9.8613554e-01  -2.5728390e-01  -1.8454544e-01
   9.7839018e-01  -1.1962181e+00  -2.8342242e-01  -2.4506191e-01
   6.7857338e-01  -1.4762594e+00  -3.3512752e-01  -3.3396931e-01
   3.0813515e-01  -1.8641568e+00  -3.7553782e-01  -3.9091655e-01
  -7.2502262e-02  -2.2580925e+00  -3.2727074e-01  -3.1513960e-01
  -3.4640633e-01  -2.4944360e+00  -2.8582962e-01  -2.0094573e-01
  -6.4416150e-01  -2.6599839e+00  -2.9335209e-01  -9.3774236e-02
  -9.3311051e-01  -2.6819844e+00  -2.9488789e-01   7.9303745e-02
  -1.2339373e+00  -2.5013764e+00  -2.9067267e-01   3.0030151e-01
  -1.5144558e+00  -2.0813814e+00  -2.3212972e-01   4.3514870e-01
  -1.6981967e+00  -1.6310790e+00  -1.5268708e-01   4.2769331e-01
  -1.8198300e+00  -1.2259948e+00  -1.0477615e-01   3.9064105e-01
  -1.9077490e+00  -8.4979692e-01  -7.5220260e-02   3.6535882e-01
  -1.9702705e+00  -4.9527714e-01  -5.0581638e-02   3.6205433e-01
  -2.0089123e+00  -1.2568827e-01  -2.1062521e-02   2.5210788e-01
  -2.0123956e+00   8.9386143e-03   3.0282864e-04   1.2309766e-01
  -2.0083067e+00   1.2050706e-01   6.8649971e-03   9.9618557e-02
  -1.9986656e+00   2.0817573e-01   1.3888147e-02   8.8106964e-02
  -1.9805304e+00   2.9672099e-01   2.3493137e-02   8.6338440e-02
  -1.9516793e+00   3.8085261e-01   3.5410665e-02   8.1071630e-02
  -1.9097090e+00   4.5886425e-01   5.0163597e-02   7.5567335e-02
  -1.8513521e+00   5.3198728e-01   6.8987037e-02   7.2592965e-02
  -1.7717350e+00   6.0405018e-01   9.3861320e-02   7.5023456e-02
  -1.6636295e+00   6.8203419e-01   1.2695354e-01   8.6590129e-02
  -1.5178279e+00   7.7723043e-01   1.6794491e-01   1.1147654e-01
  -1.3277396e+00   9.0498727e-01   2.1102387e-01   1.5165932e-01
  -1.0957801e+00   1.0805491e+00   2.5111312e-01   2.0673793e-01
  -8.2551340e-01   1.3184631e+00   2.9784340e-01   2.8265936e-01
  -5.0009333e-01   1.6458678e+00   3.4815941e-01   3.6122922e-01
  -1.2919459e-01   2.0409216e+00   3.2602662e-01   3.3665136e-01
   1.5195992e-01   2.3191705e+00   2.9838308e-01   2.6066088e-01
   4.6757156e-01   2.5622433e+00   3.0601859e-01   1.7770385e-01
   7.6399710e-01   2.6745782e+00   2.9247767e-01   3.0969255e-02
   1.0525269e+00   2.6241818e+00   2.9128230e-01  -1.6186784e-01
   1.3465617e+00   2.3508425e+00   2.4601433e-01  -3.1068418e-01
   1.5445556e+00   2.0028135e+00   1.8044909e-01  -3.8204061e-01
   1.7074599e+00   1.5867613e+00   1.4017150e-01  -4.0752963e-01
   1.8248986e+00   1.1877542e+00   1.0140544e-01  -3.8573509e-01
   1.9102708e+00   8.1529110e-01   7.2859882e-02  -3.6218176e-01
   1.9706183e+00   4.6339070e-01   4.8189777e-02  -3.6427720e-01
   2.0066503e+00   8.6736710e-02   1.8659083e-02  -2.5250145e-01
   2.0079365e+00  -4.1612193e-02  -2.3401563e-03  -1.1731702e-01
   2.0019700e+00  -1.4789733e-01  -9.0772045e-03  -9.7747464e-02
   1.9897821e+00  -2.3710712e-01  -1.6821048e-02  -8.8513394e-02
   1.9683279e+00  -3.2492411e-01  -2.7205202e-02  -8.5150927e-02
   1.9353717e+00  -4.0740897e-01  -4.0019478e-02  -7.9494340e-02
   1.8882889e+00  -4.8391279e-01  -5.6006188e-02  -7.4560642e-02
   1.8233593e+00  -5.5653026e-01  -7.6650078e-02  -7.3072124e-02
   1.7349888e+00  -6.3005704e-01  -1.0411806e-01  -7.8144155e-02
   1.6151232e+00  -7.1281857e-01  -1.4016767e-01  -9.3828091e-02
   1.4546534e+00  -8.1771323e-01  -1.8273477e-01  -1.2392570e-01
   1.2496536e+00  -9.6066996e-01  -2.2499040e-01  -1.6927601e-01
   1.0046726e+00  -1.1562652e+00  -2.6534157e-01  -2.3022966e-01
   7.1897052e-01  -1.4211293e+00  -3.2260991e-01  -3.1949462e-01
   3.5945282e-01  -1.7952545e+00  -3.6834533e-01  -3.8483364e-01
  -1.7720148e-02  -2.1907966e+00  -3.2545170e-01  -3.2153939e-01
  -2.9145058e-01  -2.4383333e+00  -2.8694493e-01  -2.1743893e-01
  -5.9161002e-01  -2.6256744e+00  -2.9488168e-01  -1.1876703e-01
  -8.8121394e-01  -2.6758673e+00  -2.9212345e-01   4.2654315e-02
  -1.1758569e+00  -2.5403658e+00  -2.8958294e-01   2.5354649e-01
  -1.4603798e+00  -2.1687743e+00  -2.4488695e-01   4.1728897e-01
  -1.6656308e+00  -1.7057879e+00  -1.4133867e-01   3.4676055e-01
  -1.7430571e+00  -1.4752532e+00  -7.7426317e-02   2.3053465e-01


Edit: I added some data that I've accumulated from MATLAB simulations.

The matlab plot looks like this: [enter image description here]

The columns are 1: x 2:y 3:u 4: v

3
  • I am not sure to which extent plain quiver plot are the optimal way to produce such plots. It seems to me that these are contour lines with some (more or less) equally spaced arrow heads, so it might be advantageous to add arrows to contours which are already curved. Having said this, it is very hard to make any concrete suggestion without more concrete input. Can you provide us with some data that allows one to draw these curves in one way or another? – user194703 May 22 '20 at 2:07
  • A couple of examples. – algae May 22 '20 at 3:53
  • @Schrödinger's cat I've added some data. I hope this can help – Bakr May 22 '20 at 9:17
6

The Van der Pol Oscillator can be represented as:

$$ \dot{x}=y, \dot{y}=\mu (1-x^2)y-x $$

Simulating this system in Matlab, from different initial conditions and $\mu=0.8$, we will get trajectories that converge to a stable limit cycle.

To draw this in LaTeX, we can use Pgfplots package. We distinguish two parts:

  1. Trajectories and the limit cycle: We can export data from matlab and plot it using \addplot[options] file{filename.txt}
  2. Vector field: based on the system dynamics, we can draw the phase portrait using quiver with \addplot3

enter image description here

Here is the corresponding code:

\documentclass[border=0.2cm]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat = newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xmin = -4, xmax = 4,
    ymin = -4, ymax = 4,
    width = \textwidth,
    height = 0.7\textwidth,
    xlabel = {$x$},
    ylabel = {$y$},
    view = {0}{90},
    colormap/viridis,
    ]

\addplot3[
    point meta = {sqrt(x^2+y^2)},
    quiver = {
        u = {y/sqrt(y^2+(0.8*(1-x^2)*y-x)^2)},
        v = {(0.8*(1-x^2)*y-x)/sqrt(y^2+(0.8*(1-x^2)*y-x)^2)},
        scale arrows = 0.25,
        },
    quiver/colored = {mapped color},
    -stealth,
    domain = -4:4,
    domain y = -4:4,
    ] {0};


\addplot[very thick, red] file {data.txt};

\end{axis}
\end{tikzpicture}

\end{document}

data.txt contains your data obtained from Matlatb (x and y trajectories). In this case, it corresponds to the limit cycle (steady state trajectory). After simulation, you can extract steady state data to get only the limit cycle part and not the transient.

-1.4524 -2.0041
-1.5484 -1.8329
-1.6354 -1.6464
-1.7128 -1.4509
-1.7804 -1.2526
-1.8381 -1.0571
-1.8863 -0.86899
-1.9252 -0.69163
-1.9556 -0.52729
-1.9782 -0.37716
-1.9936 -0.24155
-2.0026 -0.12011
-2.0058 -0.012026
-2.004 0.083793
-1.9976 0.16859
-1.9873 0.24366
-1.9734 0.31025
-1.9564 0.36955
-1.9366 0.42265
-1.9142 0.47053
-1.8896 0.51406
-1.8629 0.55402
-1.8342 0.59108
-1.8038 0.62583
-1.7717 0.65879
-1.738 0.69041
-1.7027 0.72111
-1.6659 0.75124
-1.6275 0.78112
-1.5877 0.81105
-1.5464 0.8413
-1.5036 0.87212
-1.4592 0.90377
-1.4132 0.93647
-1.3655 0.97046
-1.3161 1.006
-1.2649 1.0432
-1.2118 1.0825
-1.1566 1.1239
-1.0994 1.1678
-1.0398 1.2144
-0.97786 1.264
-0.91335 1.3167
-0.84613 1.3729
-0.77601 1.4326
-0.7028 1.4961
-0.62633 1.5635
-0.54639 1.6348
-0.46279 1.7098
-0.37535 1.7884
-0.2839 1.8701
-0.18831 1.954
-0.088478 2.0392
0.015613 2.1242
0.1239 2.2068
0.23622 2.2847
0.35224 2.3547
0.4715 2.4132
0.59331 2.4563
0.7168 2.4798
0.8409 2.4798
0.96433 2.4528
1.0857 2.3965
1.2035 2.3099
1.3162 2.1938
1.4224 2.0509
1.5209 1.8853
1.6106 1.7027
1.691 1.5093
1.7615 1.3112
1.8221 1.1144
1.873 0.92364
1.9146 0.7428
1.9475 0.57444
1.9723 0.42004
1.9897 0.28015
2.0005 0.15459
2.0054 0.042661
2.005 -0.05666
2 -0.14459
1.9907 -0.2224
1.9779 -0.29137
1.9617 -0.35271
1.9427 -0.40753
1.9211 -0.45686
1.8971 -0.50159
1.871 -0.54253
1.8429 -0.58038
1.813 -0.61576
1.7814 -0.6492
1.7481 -0.68117
1.7133 -0.71211
1.6769 -0.74237
1.639 -0.77229
1.5997 -0.80218
1.5588 -0.8323
1.5164 -0.86293
1.4725 -0.89431
1.427 -0.92668
1.3798 -0.96026
1.3309 -0.9953
1.2803 -1.032
1.2277 -1.0706
1.1732 -1.1114
1.1165 -1.1546
1.0577 -1.2004
0.99643 -1.249
0.9327 -1.3008
0.8663 -1.3559
0.79705 -1.4146
0.72478 -1.4769
0.64929 -1.5432
0.5704 -1.6133
0.4879 -1.6872
0.40162 -1.7648
0.31137 -1.8456
0.21701 -1.929
0.11844 -2.014
0.015605 -2.0992
-0.091456 -2.1828
-0.20261 -2.2623
-0.31758 -2.335
-0.43594 -2.3973
-0.55707 -2.4454
-0.68017 -2.4751
-0.80422 -2.4825
-0.92799 -2.4637
-1.0501 -2.4163
-1.1691 -2.3386
-1.2835 -2.2311
-1.3917 -2.0957
-1.4926 -1.9363
-1.585 -1.7581
-1.6682 -1.5672
-1.7416 -1.3699
-1.8052 -1.1721
-1.8589 -0.97914
-1.9032 -0.79506
-1.9386 -0.62282
-1.9658 -0.46419
-1.9853 -0.32
-1.998 -0.19025
-2.0046 -0.074391
-2.0057 0.028536
-2.0019 0.1197
-1.9939 0.20037
-1.982 0.27182
-1.9668 0.3353
-1.9486 0.39194
-1.9277 0.44279
-1.9044 0.4888
-1.8789 0.53078
-1.8514 0.56948
-1.822 0.60552
-1.7909 0.63948
-1.7581 0.67185
-1.7237 0.70305
-1.6878 0.73347
-1.6504 0.76346
-1.6115 0.79333
-1.571 0.82336
-1.5291 0.85381
-1.4857 0.88494
-1.4406 0.91699
-1.3939 0.95019
-1.3456 0.98478
-1.2954 1.021
-1.2434 1.059
-1.1895 1.0991
-1.1335 1.1416
-1.0753 1.1865
-1.0148 1.2343
-0.95182 1.2852
-0.88622 1.3393
-0.81783 1.3968
-0.74647 1.4581
-0.67196 1.5232
-0.59409 1.5921
-0.51268 1.665
-0.42753 1.7415
-0.33847 1.8214
-0.24534 1.9042
-0.14803 1.9888
-0.046453 2.0741
0.059367 2.1584
0.16933 2.2394
0.28321 2.3144
0.40062 2.3802
0.52101 2.4329
0.64363 2.4685
0.76751 2.4828
0.8915 2.4722
1.0143 2.4334
1.1343 2.3647
1.2502 2.2659
1.3604 2.1384
1.4636 1.9857
1.5587 1.8124
1.6446 1.6246
1.721 1.4285
1.7874 1.2303
1.844 1.0354
1.8911 0.84837
1.9291 0.67239
1.9586 0.50961
1.9803 0.36112
1.9949 0.22714
2.0032 0.10725
2.0059 0.00061552
2.0035 -0.093896
1.9967 -0.17753
1.9859 -0.25158
1.9716 -0.31729
1.9543 -0.37584
1.9342 -0.4283
1.9116 -0.47565
1.8867 -0.51874
1.8597 -0.55834
1.8309 -0.59511
1.8003 -0.62963
1.768 -0.66242
1.734 -0.69392
1.6986 -0.72454
1.6616 -0.75462
1.6231 -0.78449
1.5832 -0.81444
1.5417 -0.84475
1.4987 -0.87565
1.4541 -0.90741
1.4079 -0.94024
1.36 -0.97439
1.3104 -1.0101
1.259 -1.0476
1.2057 -1.087
1.1503 -1.1288
1.0927 -1.173
1.0329 -1.2199
0.9707 -1.2698
0.9059 -1.3229
0.83835 -1.3794
0.76789 -1.4396
0.69433 -1.5035
0.61748 -1.5713
0.53713 -1.643
0.45311 -1.7185
0.36522 -1.7975
0.27331 -1.8794
0.17724 -1.9636
0.076929 -2.0489
-0.027641 -2.1337
-0.1364 -2.2159
-0.24915 -2.293
-0.36557 -2.3619
-0.48515 -2.4189
-0.6072 -2.46
-0.73082 -2.481
-0.8549 -2.4781
-0.97817 -2.4479
-1.0992 -2.3882
-1.2165 -2.2982
-1.3285 -2.1789
-1.4339 -2.0332
-1.5315 -1.8655
-1.6202 -1.6813
-1.6994 -1.487
-1.7688 -1.2888
-1.8283 -1.0924
-1.8782 -0.90265
-1.9188 -0.72312
-1.9507 -0.55628
-1.9746 -0.40351
-1.9913 -0.26525
-2.0014 -0.14127
-2.0056 -0.030828
-2.0047 0.067142
-1.9991 0.15386
-1.9895 0.23061
-1.9762 0.29866
-1.9597 0.35921
-1.9404 0.41336
-1.9185 0.46213
-1.8943 0.5064
-1.8679 0.54695
-1.8396 0.58449
-1.8095 0.61962
-1.7777 0.65288
-1.7442 0.68472
-1.7092 0.71556
-1.6727 0.74576
-1.6347 0.77566
-1.5951 0.80556
-1.5541 0.83574
-1.5115 0.86644
-1.4674 0.89792
-1.4217 0.93041
-1.3744 0.96415
-1.3253 0.99936
-1.2744 1.0363
-1.2216 1.0751
-1.1669 1.1162
-1.11 1.1596
-1.0509 1.2057

enter image description here

Not sure if you need to add the region inside the limit cycle. However, you can easily add an ellipse as follows:

\draw[fill=yellow,rotate around={25:(axis cs:0,0)}] (axis cs:0,0) ellipse (1.6 and 1.4);

enter image description here

5
  • This was really helpful, thank you – Bakr May 22 '20 at 12:21
  • I cant get the ellipse to look this way in my plot. What unit of measure should I use? – Bakr May 22 '20 at 12:28
  • you have to add it inside the axis environment to use the plot units. – LaTeXdraw-com May 22 '20 at 12:32
  • it is inside but i get like a rotated rectangle, so it has to be some type of unit mistake i'd say. Btw the (1.6 and 1.4) are not working for me. Everything else is fine – Bakr May 22 '20 at 12:32
  • I am not sure what kind of errors you've got. (1.6 and 1.4) are the x and y-radius of the ellipse. The ellipse is rotated with respect to its center which is (axis cs:0,0). It should be noted that the coordinate (axis cs:0,0) is different from (0,0). The first one corresponds to the coordinates of your axis. The second one is the (0,0) of the illustration which is located somewhere in the bottom left of the plot. – LaTeXdraw-com May 22 '20 at 12:40
2

Based on your data (+ added column headers), here is what comes using a pgfplots quiverplot

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage{pgfplotstable}
\pgfplotstableread{
   x               y               u              v 
   5.0000000e+00   5.0000000e+00   1.5375045e-02  -3.8620859e-01
   5.0153750e+00   4.6137914e+00   3.4876123e-02  -8.9247723e-01
   5.0697522e+00   3.2150455e+00   4.7120884e-02  -1.2339311e+00
   5.1096168e+00   2.1459291e+00   3.2612691e-02  -8.9119732e-01
   5.1349776e+00   1.4326509e+00   2.0692523e-02  -5.9536377e-01
   5.1510019e+00   9.5520159e-01   1.3088303e-02  -4.0194104e-01
   5.1611542e+00   6.2876881e-01   8.2438303e-03  -2.7656489e-01
   5.1674895e+00   4.0207181e-01   5.0626974e-03  -1.9276422e-01
   5.1712796e+00   2.4324037e-01   2.9348841e-03  -1.3523094e-01
   5.1733593e+00   1.3160992e-01   1.5130955e-03  -9.4896595e-02
   5.1743058e+00   5.3447176e-02   5.8677480e-04  -6.1018779e-02
   5.1745328e+00   9.5723602e-03   8.0115214e-05  -4.0088716e-02
   5.1744660e+00  -2.6730257e-02  -1.5404170e-04  -3.0781832e-02
   5.1742248e+00  -5.1991305e-02  -3.8495104e-04  -2.6463713e-02
   5.1736961e+00  -7.9657682e-02  -7.2776314e-04  -2.7461272e-02
   5.1727692e+00  -1.0691385e-01  -1.1781516e-03  -2.6064072e-02
   5.1713398e+00  -1.3178583e-01  -1.7339165e-03  -2.3080854e-02
   5.1693014e+00  -1.5307556e-01  -2.4070299e-03  -1.9218339e-02
   5.1665258e+00  -1.7022250e-01  -3.2386956e-03  -1.5049417e-02
   5.1628240e+00  -1.8317439e-01  -4.3388471e-03  -1.1024378e-02
   5.1578481e+00  -1.9227126e-01  -6.0468154e-03  -7.5010259e-03
   5.1507304e+00  -1.9817644e-01  -8.1222890e-03  -4.3633595e-03
   5.1416035e+00  -2.0099798e-01  -9.1715588e-03  -1.9070612e-03
   5.1323873e+00  -2.0199056e-01  -1.3417789e-02  -1.0268839e-03
   5.1147679e+00  -2.0305175e-01  -1.7661691e-02  -8.2170241e-04
   5.0970639e+00  -2.0363397e-01  -2.2391117e-02  -9.9109217e-04
   5.0699857e+00  -2.0503393e-01  -2.3287887e-02  -9.7531501e-04
   5.0504881e+00  -2.0558460e-01  -1.9527635e-02  -8.1399390e-04
   5.0309304e+00  -2.0666192e-01  -2.3042819e-02  -9.7717744e-04
   5.0044025e+00  -2.0753895e-01  -2.3418200e-02  -1.0761901e-03
   4.9840940e+00  -2.0881430e-01  -2.0366409e-02  -9.6606661e-04
   4.9636696e+00  -2.0947109e-01  -2.3082076e-02  -1.0687046e-03
   4.9379299e+00  -2.1095171e-01  -2.6011741e-02  -1.0815549e-03
   4.9116462e+00  -2.1163420e-01  -2.4149461e-02  -1.1651869e-03
   4.8896310e+00  -2.1328208e-01  -2.1354325e-02  -1.0932455e-03
   4.8689375e+00  -2.1382069e-01  -2.2031356e-02  -9.8070964e-04
   4.8455682e+00  -2.1524350e-01  -2.5224340e-02  -1.1723750e-03
   4.8184888e+00  -2.1616544e-01  -2.6552952e-02  -1.3619678e-03
   4.7924623e+00  -2.1796744e-01  -2.4875557e-02  -1.2204887e-03
   4.7687377e+00  -2.1860641e-01  -2.3647924e-02  -1.1125943e-03
   4.7451665e+00  -2.2019263e-01  -2.4990119e-02  -1.2789247e-03
   4.7187575e+00  -2.2116426e-01  -2.7204798e-02  -1.4193725e-03
   4.6907569e+00  -2.2303137e-01  -2.7720404e-02  -1.3878697e-03
   4.6633167e+00  -2.2394000e-01  -2.6718927e-02  -1.3822717e-03
   4.6373190e+00  -2.2579592e-01  -2.6499987e-02  -1.4375387e-03
   4.6103167e+00  -2.2681508e-01  -2.7907499e-02  -1.4895473e-03
   4.5815040e+00  -2.2877501e-01  -2.9544655e-02  -1.5751089e-03
   4.5512274e+00  -2.2996530e-01  -2.9815198e-02  -1.6623333e-03
   4.5218736e+00  -2.3209968e-01  -2.9370497e-02  -1.6568117e-03
   4.4924864e+00  -2.3327892e-01  -2.9796693e-02  -1.6701997e-03
   4.4622803e+00  -2.3544008e-01  -3.1298785e-02  -1.7978494e-03
   4.4298888e+00  -2.3687462e-01  -3.2502356e-02  -1.9229918e-03
   4.3972755e+00  -2.3928606e-01  -3.2808898e-02  -1.9458717e-03
   4.3642710e+00  -2.4076636e-01  -3.2973966e-02  -1.9846557e-03
   4.3313276e+00  -2.4325537e-01  -3.3929627e-02  -2.0981889e-03
   4.2964118e+00  -2.4496274e-01  -3.5330052e-02  -2.2230522e-03
   4.2606675e+00  -2.4770148e-01  -3.6500550e-02  -2.3201369e-03
   4.2234107e+00  -2.4960302e-01  -3.7109322e-02  -2.4210438e-03
   4.1864489e+00  -2.5254356e-01  -3.7866850e-02  -2.5258135e-03
   4.1476770e+00  -2.5465464e-01  -3.9130255e-02  -2.6549304e-03
   4.1081884e+00  -2.5785342e-01  -4.0829064e-02  -2.8266337e-03
   4.0660188e+00  -2.6030791e-01  -4.2127466e-02  -3.0008646e-03
   4.0239334e+00  -2.6385515e-01  -4.3290003e-02  -3.1505155e-03
   3.9794388e+00  -2.6660894e-01  -4.4613726e-02  -3.3248984e-03
   3.9347060e+00  -2.7050495e-01  -4.6660425e-02  -3.5725176e-03
   3.8861180e+00  -2.7375398e-01  -4.8596167e-02  -3.8338285e-03
   3.8375136e+00  -2.7817261e-01  -5.0694549e-02  -4.1079148e-03
   3.7847289e+00  -2.8196981e-01  -5.2563008e-02  -4.3978063e-03
   3.7323876e+00  -2.8696822e-01  -5.5288920e-02  -4.7822653e-03
   3.6741511e+00  -2.9153434e-01  -5.7922409e-02  -5.1901599e-03
   3.6165428e+00  -2.9734854e-01  -6.1603931e-02  -5.7265594e-03
   3.5509432e+00  -3.0298746e-01  -6.4589583e-02  -6.2588600e-03
   3.4873636e+00  -3.0986626e-01  -6.9210468e-02  -7.0094933e-03
   3.4125223e+00  -3.1700644e-01  -7.3036226e-02  -7.7519262e-03
   3.3412912e+00  -3.2537011e-01  -8.0258291e-02  -8.9849554e-03
   3.2520057e+00  -3.3497635e-01  -8.5032194e-02  -1.0080538e-02
   3.1712268e+00  -3.4553119e-01  -9.5834397e-02  -1.2154307e-02
   3.0603369e+00  -3.5928497e-01  -1.0165388e-01  -1.3825426e-02
   2.9679190e+00  -3.7318204e-01  -9.5628158e-02  -1.4342106e-02
   2.8690806e+00  -3.8796918e-01  -1.0089907e-01  -1.5993383e-02
   2.7661209e+00  -4.0516881e-01  -1.3008578e-01  -2.2923141e-02
   2.6089090e+00  -4.3381546e-01  -1.4845392e-01  -2.9258572e-02
   2.4692130e+00  -4.6368595e-01  -1.5682481e-01  -3.5970836e-02
   2.2952594e+00  -5.0575713e-01  -1.7213529e-01  -4.5530553e-02
   2.1249425e+00  -5.5474706e-01  -1.8138057e-01  -5.7431808e-02
   1.9324982e+00  -6.2062075e-01  -2.0120486e-01  -7.6809066e-02
   1.7225327e+00  -7.0836519e-01  -2.1977012e-01  -1.0325325e-01
   1.4929580e+00  -8.2712725e-01  -2.3855726e-01  -1.3888518e-01
   1.2454182e+00  -9.8613554e-01  -2.5728390e-01  -1.8454544e-01
   9.7839018e-01  -1.1962181e+00  -2.8342242e-01  -2.4506191e-01
   6.7857338e-01  -1.4762594e+00  -3.3512752e-01  -3.3396931e-01
   3.0813515e-01  -1.8641568e+00  -3.7553782e-01  -3.9091655e-01
  -7.2502262e-02  -2.2580925e+00  -3.2727074e-01  -3.1513960e-01
  -3.4640633e-01  -2.4944360e+00  -2.8582962e-01  -2.0094573e-01
  -6.4416150e-01  -2.6599839e+00  -2.9335209e-01  -9.3774236e-02
  -9.3311051e-01  -2.6819844e+00  -2.9488789e-01   7.9303745e-02
  -1.2339373e+00  -2.5013764e+00  -2.9067267e-01   3.0030151e-01
  -1.5144558e+00  -2.0813814e+00  -2.3212972e-01   4.3514870e-01
  -1.6981967e+00  -1.6310790e+00  -1.5268708e-01   4.2769331e-01
  -1.8198300e+00  -1.2259948e+00  -1.0477615e-01   3.9064105e-01
  -1.9077490e+00  -8.4979692e-01  -7.5220260e-02   3.6535882e-01
  -1.9702705e+00  -4.9527714e-01  -5.0581638e-02   3.6205433e-01
  -2.0089123e+00  -1.2568827e-01  -2.1062521e-02   2.5210788e-01
  -2.0123956e+00   8.9386143e-03   3.0282864e-04   1.2309766e-01
  -2.0083067e+00   1.2050706e-01   6.8649971e-03   9.9618557e-02
  -1.9986656e+00   2.0817573e-01   1.3888147e-02   8.8106964e-02
  -1.9805304e+00   2.9672099e-01   2.3493137e-02   8.6338440e-02
  -1.9516793e+00   3.8085261e-01   3.5410665e-02   8.1071630e-02
  -1.9097090e+00   4.5886425e-01   5.0163597e-02   7.5567335e-02
  -1.8513521e+00   5.3198728e-01   6.8987037e-02   7.2592965e-02
  -1.7717350e+00   6.0405018e-01   9.3861320e-02   7.5023456e-02
  -1.6636295e+00   6.8203419e-01   1.2695354e-01   8.6590129e-02
  -1.5178279e+00   7.7723043e-01   1.6794491e-01   1.1147654e-01
  -1.3277396e+00   9.0498727e-01   2.1102387e-01   1.5165932e-01
  -1.0957801e+00   1.0805491e+00   2.5111312e-01   2.0673793e-01
  -8.2551340e-01   1.3184631e+00   2.9784340e-01   2.8265936e-01
  -5.0009333e-01   1.6458678e+00   3.4815941e-01   3.6122922e-01
  -1.2919459e-01   2.0409216e+00   3.2602662e-01   3.3665136e-01
   1.5195992e-01   2.3191705e+00   2.9838308e-01   2.6066088e-01
   4.6757156e-01   2.5622433e+00   3.0601859e-01   1.7770385e-01
   7.6399710e-01   2.6745782e+00   2.9247767e-01   3.0969255e-02
   1.0525269e+00   2.6241818e+00   2.9128230e-01  -1.6186784e-01
   1.3465617e+00   2.3508425e+00   2.4601433e-01  -3.1068418e-01
   1.5445556e+00   2.0028135e+00   1.8044909e-01  -3.8204061e-01
   1.7074599e+00   1.5867613e+00   1.4017150e-01  -4.0752963e-01
   1.8248986e+00   1.1877542e+00   1.0140544e-01  -3.8573509e-01
   1.9102708e+00   8.1529110e-01   7.2859882e-02  -3.6218176e-01
   1.9706183e+00   4.6339070e-01   4.8189777e-02  -3.6427720e-01
   2.0066503e+00   8.6736710e-02   1.8659083e-02  -2.5250145e-01
   2.0079365e+00  -4.1612193e-02  -2.3401563e-03  -1.1731702e-01
   2.0019700e+00  -1.4789733e-01  -9.0772045e-03  -9.7747464e-02
   1.9897821e+00  -2.3710712e-01  -1.6821048e-02  -8.8513394e-02
   1.9683279e+00  -3.2492411e-01  -2.7205202e-02  -8.5150927e-02
   1.9353717e+00  -4.0740897e-01  -4.0019478e-02  -7.9494340e-02
   1.8882889e+00  -4.8391279e-01  -5.6006188e-02  -7.4560642e-02
   1.8233593e+00  -5.5653026e-01  -7.6650078e-02  -7.3072124e-02
   1.7349888e+00  -6.3005704e-01  -1.0411806e-01  -7.8144155e-02
   1.6151232e+00  -7.1281857e-01  -1.4016767e-01  -9.3828091e-02
   1.4546534e+00  -8.1771323e-01  -1.8273477e-01  -1.2392570e-01
   1.2496536e+00  -9.6066996e-01  -2.2499040e-01  -1.6927601e-01
   1.0046726e+00  -1.1562652e+00  -2.6534157e-01  -2.3022966e-01
   7.1897052e-01  -1.4211293e+00  -3.2260991e-01  -3.1949462e-01
   3.5945282e-01  -1.7952545e+00  -3.6834533e-01  -3.8483364e-01
  -1.7720148e-02  -2.1907966e+00  -3.2545170e-01  -3.2153939e-01
  -2.9145058e-01  -2.4383333e+00  -2.8694493e-01  -2.1743893e-01
  -5.9161002e-01  -2.6256744e+00  -2.9488168e-01  -1.1876703e-01
  -8.8121394e-01  -2.6758673e+00  -2.9212345e-01   4.2654315e-02
  -1.1758569e+00  -2.5403658e+00  -2.8958294e-01   2.5354649e-01
  -1.4603798e+00  -2.1687743e+00  -2.4488695e-01   4.1728897e-01
  -1.6656308e+00  -1.7057879e+00  -1.4133867e-01   3.4676055e-01
  -1.7430571e+00  -1.4752532e+00  -7.7426317e-02   2.3053465e-01
}\loadedtable

\begin{document}
\begin{tikzpicture}    
    \begin{axis}
        \addplot[-stealth,red,quiver={u=\thisrow{u},v=\thisrow{v}}] table {\loadedtable};
    \end{axis}
\end{tikzpicture}
\end{document}

And here is another solution without column headers based on the column index, using an external file as the data source

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{filecontents*}{mydata.tsv}
   5.0000000e+00   5.0000000e+00   1.5375045e-02  -3.8620859e-01
   5.0153750e+00   4.6137914e+00   3.4876123e-02  -8.9247723e-01
   5.0697522e+00   3.2150455e+00   4.7120884e-02  -1.2339311e+00
   5.1096168e+00   2.1459291e+00   3.2612691e-02  -8.9119732e-01
   5.1349776e+00   1.4326509e+00   2.0692523e-02  -5.9536377e-01
   5.1510019e+00   9.5520159e-01   1.3088303e-02  -4.0194104e-01
   5.1611542e+00   6.2876881e-01   8.2438303e-03  -2.7656489e-01
   5.1674895e+00   4.0207181e-01   5.0626974e-03  -1.9276422e-01
   5.1712796e+00   2.4324037e-01   2.9348841e-03  -1.3523094e-01
   5.1733593e+00   1.3160992e-01   1.5130955e-03  -9.4896595e-02
   5.1743058e+00   5.3447176e-02   5.8677480e-04  -6.1018779e-02
   5.1745328e+00   9.5723602e-03   8.0115214e-05  -4.0088716e-02
   5.1744660e+00  -2.6730257e-02  -1.5404170e-04  -3.0781832e-02
   5.1742248e+00  -5.1991305e-02  -3.8495104e-04  -2.6463713e-02
   5.1736961e+00  -7.9657682e-02  -7.2776314e-04  -2.7461272e-02
   5.1727692e+00  -1.0691385e-01  -1.1781516e-03  -2.6064072e-02
   5.1713398e+00  -1.3178583e-01  -1.7339165e-03  -2.3080854e-02
   5.1693014e+00  -1.5307556e-01  -2.4070299e-03  -1.9218339e-02
   5.1665258e+00  -1.7022250e-01  -3.2386956e-03  -1.5049417e-02
   5.1628240e+00  -1.8317439e-01  -4.3388471e-03  -1.1024378e-02
   5.1578481e+00  -1.9227126e-01  -6.0468154e-03  -7.5010259e-03
   5.1507304e+00  -1.9817644e-01  -8.1222890e-03  -4.3633595e-03
   5.1416035e+00  -2.0099798e-01  -9.1715588e-03  -1.9070612e-03
   5.1323873e+00  -2.0199056e-01  -1.3417789e-02  -1.0268839e-03
   5.1147679e+00  -2.0305175e-01  -1.7661691e-02  -8.2170241e-04
   5.0970639e+00  -2.0363397e-01  -2.2391117e-02  -9.9109217e-04
   5.0699857e+00  -2.0503393e-01  -2.3287887e-02  -9.7531501e-04
   5.0504881e+00  -2.0558460e-01  -1.9527635e-02  -8.1399390e-04
   5.0309304e+00  -2.0666192e-01  -2.3042819e-02  -9.7717744e-04
   5.0044025e+00  -2.0753895e-01  -2.3418200e-02  -1.0761901e-03
   4.9840940e+00  -2.0881430e-01  -2.0366409e-02  -9.6606661e-04
   4.9636696e+00  -2.0947109e-01  -2.3082076e-02  -1.0687046e-03
   4.9379299e+00  -2.1095171e-01  -2.6011741e-02  -1.0815549e-03
   4.9116462e+00  -2.1163420e-01  -2.4149461e-02  -1.1651869e-03
   4.8896310e+00  -2.1328208e-01  -2.1354325e-02  -1.0932455e-03
   4.8689375e+00  -2.1382069e-01  -2.2031356e-02  -9.8070964e-04
   4.8455682e+00  -2.1524350e-01  -2.5224340e-02  -1.1723750e-03
   4.8184888e+00  -2.1616544e-01  -2.6552952e-02  -1.3619678e-03
   4.7924623e+00  -2.1796744e-01  -2.4875557e-02  -1.2204887e-03
   4.7687377e+00  -2.1860641e-01  -2.3647924e-02  -1.1125943e-03
   4.7451665e+00  -2.2019263e-01  -2.4990119e-02  -1.2789247e-03
   4.7187575e+00  -2.2116426e-01  -2.7204798e-02  -1.4193725e-03
   4.6907569e+00  -2.2303137e-01  -2.7720404e-02  -1.3878697e-03
   4.6633167e+00  -2.2394000e-01  -2.6718927e-02  -1.3822717e-03
   4.6373190e+00  -2.2579592e-01  -2.6499987e-02  -1.4375387e-03
   4.6103167e+00  -2.2681508e-01  -2.7907499e-02  -1.4895473e-03
   4.5815040e+00  -2.2877501e-01  -2.9544655e-02  -1.5751089e-03
   4.5512274e+00  -2.2996530e-01  -2.9815198e-02  -1.6623333e-03
   4.5218736e+00  -2.3209968e-01  -2.9370497e-02  -1.6568117e-03
   4.4924864e+00  -2.3327892e-01  -2.9796693e-02  -1.6701997e-03
   4.4622803e+00  -2.3544008e-01  -3.1298785e-02  -1.7978494e-03
   4.4298888e+00  -2.3687462e-01  -3.2502356e-02  -1.9229918e-03
   4.3972755e+00  -2.3928606e-01  -3.2808898e-02  -1.9458717e-03
   4.3642710e+00  -2.4076636e-01  -3.2973966e-02  -1.9846557e-03
   4.3313276e+00  -2.4325537e-01  -3.3929627e-02  -2.0981889e-03
   4.2964118e+00  -2.4496274e-01  -3.5330052e-02  -2.2230522e-03
   4.2606675e+00  -2.4770148e-01  -3.6500550e-02  -2.3201369e-03
   4.2234107e+00  -2.4960302e-01  -3.7109322e-02  -2.4210438e-03
   4.1864489e+00  -2.5254356e-01  -3.7866850e-02  -2.5258135e-03
   4.1476770e+00  -2.5465464e-01  -3.9130255e-02  -2.6549304e-03
   4.1081884e+00  -2.5785342e-01  -4.0829064e-02  -2.8266337e-03
   4.0660188e+00  -2.6030791e-01  -4.2127466e-02  -3.0008646e-03
   4.0239334e+00  -2.6385515e-01  -4.3290003e-02  -3.1505155e-03
   3.9794388e+00  -2.6660894e-01  -4.4613726e-02  -3.3248984e-03
   3.9347060e+00  -2.7050495e-01  -4.6660425e-02  -3.5725176e-03
   3.8861180e+00  -2.7375398e-01  -4.8596167e-02  -3.8338285e-03
   3.8375136e+00  -2.7817261e-01  -5.0694549e-02  -4.1079148e-03
   3.7847289e+00  -2.8196981e-01  -5.2563008e-02  -4.3978063e-03
   3.7323876e+00  -2.8696822e-01  -5.5288920e-02  -4.7822653e-03
   3.6741511e+00  -2.9153434e-01  -5.7922409e-02  -5.1901599e-03
   3.6165428e+00  -2.9734854e-01  -6.1603931e-02  -5.7265594e-03
   3.5509432e+00  -3.0298746e-01  -6.4589583e-02  -6.2588600e-03
   3.4873636e+00  -3.0986626e-01  -6.9210468e-02  -7.0094933e-03
   3.4125223e+00  -3.1700644e-01  -7.3036226e-02  -7.7519262e-03
   3.3412912e+00  -3.2537011e-01  -8.0258291e-02  -8.9849554e-03
   3.2520057e+00  -3.3497635e-01  -8.5032194e-02  -1.0080538e-02
   3.1712268e+00  -3.4553119e-01  -9.5834397e-02  -1.2154307e-02
   3.0603369e+00  -3.5928497e-01  -1.0165388e-01  -1.3825426e-02
   2.9679190e+00  -3.7318204e-01  -9.5628158e-02  -1.4342106e-02
   2.8690806e+00  -3.8796918e-01  -1.0089907e-01  -1.5993383e-02
   2.7661209e+00  -4.0516881e-01  -1.3008578e-01  -2.2923141e-02
   2.6089090e+00  -4.3381546e-01  -1.4845392e-01  -2.9258572e-02
   2.4692130e+00  -4.6368595e-01  -1.5682481e-01  -3.5970836e-02
   2.2952594e+00  -5.0575713e-01  -1.7213529e-01  -4.5530553e-02
   2.1249425e+00  -5.5474706e-01  -1.8138057e-01  -5.7431808e-02
   1.9324982e+00  -6.2062075e-01  -2.0120486e-01  -7.6809066e-02
   1.7225327e+00  -7.0836519e-01  -2.1977012e-01  -1.0325325e-01
   1.4929580e+00  -8.2712725e-01  -2.3855726e-01  -1.3888518e-01
   1.2454182e+00  -9.8613554e-01  -2.5728390e-01  -1.8454544e-01
   9.7839018e-01  -1.1962181e+00  -2.8342242e-01  -2.4506191e-01
   6.7857338e-01  -1.4762594e+00  -3.3512752e-01  -3.3396931e-01
   3.0813515e-01  -1.8641568e+00  -3.7553782e-01  -3.9091655e-01
  -7.2502262e-02  -2.2580925e+00  -3.2727074e-01  -3.1513960e-01
  -3.4640633e-01  -2.4944360e+00  -2.8582962e-01  -2.0094573e-01
  -6.4416150e-01  -2.6599839e+00  -2.9335209e-01  -9.3774236e-02
  -9.3311051e-01  -2.6819844e+00  -2.9488789e-01   7.9303745e-02
  -1.2339373e+00  -2.5013764e+00  -2.9067267e-01   3.0030151e-01
  -1.5144558e+00  -2.0813814e+00  -2.3212972e-01   4.3514870e-01
  -1.6981967e+00  -1.6310790e+00  -1.5268708e-01   4.2769331e-01
  -1.8198300e+00  -1.2259948e+00  -1.0477615e-01   3.9064105e-01
  -1.9077490e+00  -8.4979692e-01  -7.5220260e-02   3.6535882e-01
  -1.9702705e+00  -4.9527714e-01  -5.0581638e-02   3.6205433e-01
  -2.0089123e+00  -1.2568827e-01  -2.1062521e-02   2.5210788e-01
  -2.0123956e+00   8.9386143e-03   3.0282864e-04   1.2309766e-01
  -2.0083067e+00   1.2050706e-01   6.8649971e-03   9.9618557e-02
  -1.9986656e+00   2.0817573e-01   1.3888147e-02   8.8106964e-02
  -1.9805304e+00   2.9672099e-01   2.3493137e-02   8.6338440e-02
  -1.9516793e+00   3.8085261e-01   3.5410665e-02   8.1071630e-02
  -1.9097090e+00   4.5886425e-01   5.0163597e-02   7.5567335e-02
  -1.8513521e+00   5.3198728e-01   6.8987037e-02   7.2592965e-02
  -1.7717350e+00   6.0405018e-01   9.3861320e-02   7.5023456e-02
  -1.6636295e+00   6.8203419e-01   1.2695354e-01   8.6590129e-02
  -1.5178279e+00   7.7723043e-01   1.6794491e-01   1.1147654e-01
  -1.3277396e+00   9.0498727e-01   2.1102387e-01   1.5165932e-01
  -1.0957801e+00   1.0805491e+00   2.5111312e-01   2.0673793e-01
  -8.2551340e-01   1.3184631e+00   2.9784340e-01   2.8265936e-01
  -5.0009333e-01   1.6458678e+00   3.4815941e-01   3.6122922e-01
  -1.2919459e-01   2.0409216e+00   3.2602662e-01   3.3665136e-01
   1.5195992e-01   2.3191705e+00   2.9838308e-01   2.6066088e-01
   4.6757156e-01   2.5622433e+00   3.0601859e-01   1.7770385e-01
   7.6399710e-01   2.6745782e+00   2.9247767e-01   3.0969255e-02
   1.0525269e+00   2.6241818e+00   2.9128230e-01  -1.6186784e-01
   1.3465617e+00   2.3508425e+00   2.4601433e-01  -3.1068418e-01
   1.5445556e+00   2.0028135e+00   1.8044909e-01  -3.8204061e-01
   1.7074599e+00   1.5867613e+00   1.4017150e-01  -4.0752963e-01
   1.8248986e+00   1.1877542e+00   1.0140544e-01  -3.8573509e-01
   1.9102708e+00   8.1529110e-01   7.2859882e-02  -3.6218176e-01
   1.9706183e+00   4.6339070e-01   4.8189777e-02  -3.6427720e-01
   2.0066503e+00   8.6736710e-02   1.8659083e-02  -2.5250145e-01
   2.0079365e+00  -4.1612193e-02  -2.3401563e-03  -1.1731702e-01
   2.0019700e+00  -1.4789733e-01  -9.0772045e-03  -9.7747464e-02
   1.9897821e+00  -2.3710712e-01  -1.6821048e-02  -8.8513394e-02
   1.9683279e+00  -3.2492411e-01  -2.7205202e-02  -8.5150927e-02
   1.9353717e+00  -4.0740897e-01  -4.0019478e-02  -7.9494340e-02
   1.8882889e+00  -4.8391279e-01  -5.6006188e-02  -7.4560642e-02
   1.8233593e+00  -5.5653026e-01  -7.6650078e-02  -7.3072124e-02
   1.7349888e+00  -6.3005704e-01  -1.0411806e-01  -7.8144155e-02
   1.6151232e+00  -7.1281857e-01  -1.4016767e-01  -9.3828091e-02
   1.4546534e+00  -8.1771323e-01  -1.8273477e-01  -1.2392570e-01
   1.2496536e+00  -9.6066996e-01  -2.2499040e-01  -1.6927601e-01
   1.0046726e+00  -1.1562652e+00  -2.6534157e-01  -2.3022966e-01
   7.1897052e-01  -1.4211293e+00  -3.2260991e-01  -3.1949462e-01
   3.5945282e-01  -1.7952545e+00  -3.6834533e-01  -3.8483364e-01
  -1.7720148e-02  -2.1907966e+00  -3.2545170e-01  -3.2153939e-01
  -2.9145058e-01  -2.4383333e+00  -2.8694493e-01  -2.1743893e-01
  -5.9161002e-01  -2.6256744e+00  -2.9488168e-01  -1.1876703e-01
  -8.8121394e-01  -2.6758673e+00  -2.9212345e-01   4.2654315e-02
  -1.1758569e+00  -2.5403658e+00  -2.8958294e-01   2.5354649e-01
  -1.4603798e+00  -2.1687743e+00  -2.4488695e-01   4.1728897e-01
  -1.6656308e+00  -1.7057879e+00  -1.4133867e-01   3.4676055e-01
  -1.7430571e+00  -1.4752532e+00  -7.7426317e-02   2.3053465e-01
\end{filecontents*}

\begin{document}
\begin{tikzpicture}    
    \begin{axis}
        \addplot[-stealth,red,quiver={u=\thisrowno{2},v=\thisrowno{3}}] table[x expr=\thisrowno{0},y expr=\thisrowno{1}] {mydata.tsv};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

EDIT Here is a last proposal based on decorations as noted by @Schrödinger's cat.

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usetikzlibrary{decorations.markings,arrows.meta}
\tikzset{arrow decoration/.style={
 postaction={
  decorate,
  decoration={
   markings,
   mark=between positions 4.5mm and 1 step 5mm with {\arrow[]{stealth};}
  }
 },
 red,
 dash pattern=on 4mm off 1mm on 4mm off 1mm
}}

\begin{document}
\begin{tikzpicture}    
    \begin{axis}
        \addplot[red,arrow decoration,smooth] table[x expr=\thisrowno{0},y expr=\thisrowno{1}] {mydata.tsv};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

5
  • This is perfect. I thank you for now. I think i accidently deleted the other data sets in my loop, which is why the vector field is so short. But I should be able to solve this myself – Bakr May 22 '20 at 11:17
  • @Bakr, the arrows based on what solution ? – BambOo May 22 '20 at 12:02
  • never mind my question. I had not reloaded the page and did not see your edit. Thank you again – Bakr May 22 '20 at 12:05
  • @Bamboo this représentation of arrows is extremely pedagogic. – JeT May 22 '20 at 14:34
  • @Julien-ElieTaieb it is different from a quiver plot, but I agree, it carries some meaning too. – BambOo May 22 '20 at 14:36

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.