Related
The code below is producing double arrows. This is most noticeable in the center and along the bottom row.
Am I missing something or is this a bug of some sort? The Googlebox has yielded nothing helpful.
X = [[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22]]
Y = [[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1],
[ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2],
[ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3],
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4],
[ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5],
[ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6],
[ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7],
[ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8],
[ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9],
[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10],
[11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11],
[12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12],
[12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12],
[13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13],
[14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14],
[15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15],
[16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16],
[17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17],
[18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18],
[19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19],
[20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20],
[21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21],
[22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22],
[23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23]]
U = [[ 5.91106782e-01, 6.22366562e-01, 6.49723913e-01,
6.58423221e-01, 6.34788082e-01, 5.64001424e-01,
4.29552877e-01, 2.26181450e-01, -1.45749370e-02,
-2.33836090e-01, -3.97062982e-01, -5.07288787e-01,
-5.80344621e-01, -6.28652118e-01, -6.56798746e-01,
-6.59563028e-01, -6.18178096e-01, -5.00722193e-01,
-2.93582966e-01, -5.16521582e-02, 1.45799368e-01,
2.69658133e-01, 3.26500153e-01, 3.26768709e-01],
[ 5.77152607e-01, 5.82746773e-01, 5.76183972e-01,
5.43266956e-01, 4.66312191e-01, 3.24661378e-01,
1.07385088e-01, -1.54908642e-01, -3.91341641e-01,
-5.56849441e-01, -6.55288824e-01, -7.07393105e-01,
-7.30393353e-01, -7.34785105e-01, -7.24202206e-01,
-6.92703347e-01, -6.16664334e-01, -4.51489078e-01,
-1.96144234e-01, 3.89095593e-02, 1.80222779e-01,
2.38107484e-01, 2.33390450e-01, 1.75753839e-01],
[ 5.55201554e-01, 5.36916267e-01, 4.95331092e-01,
4.14297782e-01, 2.72441471e-01, 5.30267270e-02,
-2.23958353e-01, -4.85686407e-01, -6.72063827e-01,
-7.80930667e-01, -8.34052999e-01, -8.49154520e-01,
-8.36753045e-01, -8.02912499e-01, -7.48984464e-01,
-6.66861836e-01, -5.28032125e-01, -2.83307017e-01,
2.22999217e-02, 2.17035214e-01, 2.78107345e-01,
2.57213982e-01, 1.80414526e-01, 5.58040480e-02],
[ 5.30514869e-01, 4.88045325e-01, 4.08507605e-01,
2.73305715e-01, 6.32261747e-02, -2.15499555e-01,
-5.00468423e-01, -7.16424820e-01, -8.46362641e-01,
-9.11763344e-01, -9.32463829e-01, -9.17913774e-01,
-8.71699781e-01, -7.94959450e-01, -6.84618047e-01,
-5.27977847e-01, -3.00601184e-01, 3.24725025e-03,
2.84572480e-01, 4.15678719e-01, 4.08817699e-01,
3.17903989e-01, 1.68926905e-01, -2.47734503e-02],
[ 5.02548139e-01, 4.33179379e-01, 3.10308116e-01,
1.15832201e-01, -1.53873192e-01, -4.53740654e-01,
-7.02597717e-01, -8.60992569e-01, -9.43881451e-01,
-9.75369646e-01, -9.68057700e-01, -9.24950942e-01,
-8.45413757e-01, -7.27664488e-01, -5.66705523e-01,
-3.53336189e-01, -8.54415234e-02, 2.02537484e-01,
4.30399404e-01, 5.35069052e-01, 5.14397103e-01,
3.91608994e-01, 1.87450108e-01, -6.90256334e-02],
[ 4.65201575e-01, 3.63695264e-01, 1.90407737e-01,
-6.27986111e-02, -3.66107539e-01, -6.43527995e-01,
-8.36008710e-01, -9.43058071e-01, -9.89396085e-01,
-9.93329532e-01, -9.61559805e-01, -8.93929627e-01,
-7.88224158e-01, -6.41454775e-01, -4.49066265e-01,
-2.09439702e-01, 6.10838713e-02, 3.17493844e-01,
5.06540308e-01, 5.97919655e-01, 5.83094325e-01,
4.57218933e-01, 2.21129548e-01, -8.56001665e-02],
[ 4.07605489e-01, 2.67483222e-01, 4.05687053e-02,
-2.54052862e-01, -5.49121397e-01, -7.74824152e-01,
-9.12683654e-01, -9.80602627e-01, -9.99708951e-01,
-9.81982007e-01, -9.30930539e-01, -8.45440583e-01,
-7.22549396e-01, -5.57873670e-01, -3.47081454e-01,
-9.50528305e-02, 1.70316784e-01, 4.02869279e-01,
5.66564552e-01, 6.47406192e-01, 6.37165072e-01,
5.16241932e-01, 2.63738110e-01, -8.10456144e-02],
[ 3.16982526e-01, 1.36224084e-01, -1.31317283e-01,
-4.28869103e-01, -6.80165940e-01, -8.50494619e-01,
-9.46930042e-01, -9.87780174e-01, -9.87413002e-01,
-9.53497923e-01, -8.88237499e-01, -7.90275139e-01,
-6.55616984e-01, -4.77864944e-01, -2.52458286e-01,
9.81222811e-03, 2.71633461e-01, 4.87237886e-01,
6.32706314e-01, 7.04459838e-01, 6.96319353e-01,
5.81475147e-01, 3.21122831e-01, -5.36729232e-02],
[ 1.89851174e-01, -1.85511352e-02, -2.92612142e-01,
-5.56206782e-01, -7.55569048e-01, -8.83561174e-01,
-9.52641527e-01, -9.75602026e-01, -9.61454612e-01,
-9.15325308e-01, -8.38796591e-01, -7.30116952e-01,
-5.83859882e-01, -3.91508312e-01, -1.49024508e-01,
1.25224816e-01, 3.84250312e-01, 5.84434393e-01,
7.13492616e-01, 7.76382012e-01, 7.69585148e-01,
6.63495229e-01, 4.05530281e-01, 8.00655892e-03],
[ 4.93393011e-02, -1.59077638e-01, -4.07446556e-01,
-6.27159359e-01, -7.86840781e-01, -8.87988595e-01,
-9.40149757e-01, -9.51231448e-01, -9.26802697e-01,
-8.70250066e-01, -7.82391229e-01, -6.60618012e-01,
-4.97916636e-01, -2.84557428e-01, -2.01313492e-02,
2.65144709e-01, 5.15478531e-01, 6.95092413e-01,
8.05054050e-01, 8.57357453e-01, 8.51220724e-01,
7.58939184e-01, 5.22126402e-01, 1.20841224e-01],
[-6.08161695e-02, -2.48600589e-01, -4.63433277e-01,
-6.50364713e-01, -7.86735731e-01, -8.73048406e-01,
-9.15192518e-01, -9.18037801e-01, -8.84901395e-01,
-8.17468539e-01, -7.15217876e-01, -5.74265632e-01,
-3.86590763e-01, -1.44298331e-01, 1.42640838e-01,
4.27841719e-01, 6.54596037e-01, 8.04151106e-01,
8.90457558e-01, 9.29136623e-01, 9.21288722e-01,
8.45538031e-01, 6.51467861e-01, 2.89354206e-01],
[-1.11855856e-01, -2.76262916e-01, -4.66494984e-01,
-6.36195917e-01, -7.62707033e-01, -8.42791922e-01,
-8.79618811e-01, -8.76344309e-01, -8.34510258e-01,
-7.53704299e-01, -6.31437753e-01, -4.62760383e-01,
-2.41283252e-01, 3.19831190e-02, 3.28392442e-01,
5.90402526e-01, 7.76991386e-01, 8.90488023e-01,
9.51679598e-01, 9.75365138e-01, 9.63233139e-01,
9.01562554e-01, 7.57051594e-01, 4.78793525e-01],
[-1.02763752e-01, -2.49208456e-01, -4.25698141e-01,
-5.90445663e-01, -7.17037110e-01, -7.97411218e-01,
-8.32440059e-01, -8.24121526e-01, -7.72259450e-01,
-6.73888301e-01, -5.24476588e-01, -3.20200623e-01,
-6.29603397e-02, 2.27897175e-01, 5.06403936e-01,
7.23466314e-01, 8.64328407e-01, 9.44675955e-01,
9.84485357e-01, 9.95247332e-01, 9.78583745e-01,
9.26839981e-01, 8.22017325e-01, 6.32198023e-01],
[-4.76297792e-02, -1.80235400e-01, -3.48835361e-01,
-5.15498990e-01, -6.48860867e-01, -7.34607790e-01,
-7.70573611e-01, -7.57371172e-01, -6.92888223e-01,
-5.71674412e-01, -3.88941513e-01, -1.47948226e-01,
1.31928638e-01, 4.12166625e-01, 6.47847253e-01,
8.14343231e-01, 9.16397002e-01, 9.71963635e-01,
9.96490008e-01, 9.98129614e-01, 9.78410399e-01,
9.33624383e-01, 8.55392368e-01, 7.29066548e-01],
[ 3.44453327e-02, -8.45500183e-02, -2.44567678e-01,
-4.13390951e-01, -5.55986626e-01, -6.50278759e-01,
-6.88905719e-01, -6.69887784e-01, -5.89049719e-01,
-4.40034407e-01, -2.23153205e-01, 4.24368019e-02,
3.17706147e-01, 5.60575371e-01, 7.45372080e-01,
8.69074149e-01, 9.43218293e-01, 9.82237250e-01,
9.96859104e-01, 9.92775230e-01, 9.71548772e-01,
9.31926675e-01, 8.70952635e-01, 7.84147337e-01],
[ 1.24531829e-01, 2.14951720e-02, -1.24142269e-01,
-2.88285785e-01, -4.36332137e-01, -5.38600278e-01,
-5.79503157e-01, -5.52137571e-01, -4.50556205e-01,
-2.72020914e-01, -3.08257107e-02, 2.33881288e-01,
4.76396240e-01, 6.69624907e-01, 8.08474102e-01,
9.00042790e-01, 9.55065954e-01, 9.83283570e-01,
9.91629328e-01, 9.84084754e-01, 9.62320925e-01,
9.26691302e-01, 8.77415997e-01, 8.15482847e-01],
[ 2.08997618e-01, 1.24559020e-01, 8.48684407e-04,
-1.46598137e-01, -2.88661918e-01, -3.91618296e-01,
-4.29961569e-01, -3.89309376e-01, -2.63943288e-01,
-6.30136416e-02, 1.78668276e-01, 4.12249396e-01,
6.04758495e-01, 7.48714864e-01, 8.50152685e-01,
9.17783980e-01, 9.59112226e-01, 9.79804775e-01,
9.83901943e-01, 9.74114572e-01, 9.52212374e-01,
9.19706766e-01, 8.78912089e-01, 8.33903997e-01],
[ 2.82249691e-01, 2.18162184e-01, 1.22747194e-01,
5.37550368e-03, -1.12692673e-01, -1.99604825e-01,
-2.22963823e-01, -1.62177004e-01, -1.79584651e-02,
1.81399471e-01, 3.89284568e-01, 5.68595908e-01,
7.06857534e-01, 8.07907267e-01, 8.79716132e-01,
9.28814854e-01, 9.59433518e-01, 9.74181247e-01,
9.74926863e-01, 9.63345918e-01, 9.41247109e-01,
9.11068122e-01, 8.76727946e-01, 8.44239721e-01],
[ 3.46009504e-01, 3.03334542e-01, 2.40609727e-01,
1.64792336e-01, 9.10650256e-02, 4.46918062e-02,
5.47680721e-02, 1.36260477e-01, 2.74393229e-01,
4.32734135e-01, 5.78349795e-01, 6.96327399e-01,
7.86097123e-01, 8.52735284e-01, 9.01501863e-01,
9.35893510e-01, 9.57589073e-01, 9.67107013e-01,
9.64733890e-01, 9.51264330e-01, 9.28488288e-01,
8.99692809e-01, 8.70252069e-01, 8.47561147e-01],
[ 4.06955125e-01, 3.86836289e-01, 3.60008319e-01,
3.33800629e-01, 3.19793639e-01, 3.32294319e-01,
3.80910459e-01, 4.60529276e-01, 5.54085368e-01,
6.45433976e-01, 7.25560042e-01, 7.91585217e-01,
8.44113209e-01, 8.85113897e-01, 9.16480279e-01,
9.39239758e-01, 9.53365969e-01, 9.58045905e-01,
9.52421824e-01, 9.36509635e-01, 9.12084965e-01,
8.83417478e-01, 8.57475919e-01, 8.42768229e-01],
[ 4.75102487e-01, 4.79444876e-01, 4.91103049e-01,
5.17028392e-01, 5.61580652e-01, 6.19364889e-01,
6.75394533e-01, 7.20462603e-01, 7.57762648e-01,
7.92301360e-01, 8.25331968e-01, 8.55937836e-01,
8.83019438e-01, 9.05962858e-01, 9.24460078e-01,
9.38025098e-01, 9.45636106e-01, 9.45638264e-01,
9.36251692e-01, 9.16741704e-01, 8.89028586e-01,
8.58882429e-01, 8.35359426e-01, 8.27878351e-01],
[ 5.62693753e-01, 5.93592734e-01, 6.42845488e-01,
7.09881932e-01, 7.82737342e-01, 8.39735853e-01,
8.68496463e-01, 8.76464004e-01, 8.77560033e-01,
8.80145097e-01, 8.86486243e-01, 8.95793855e-01,
9.06385360e-01, 9.16670844e-01, 9.25375659e-01,
9.31289596e-01, 9.32857010e-01, 9.27783629e-01,
9.13322352e-01, 8.87929386e-01, 8.54220866e-01,
8.20792210e-01, 7.99707058e-01, 8.00713493e-01],
[ 6.75223956e-01, 7.28299137e-01, 7.98132045e-01,
8.70828514e-01, 9.28100696e-01, 9.58357163e-01,
9.63664076e-01, 9.54511170e-01, 9.41109289e-01,
9.29563623e-01, 9.22166117e-01, 9.18823138e-01,
9.18280235e-01, 9.18945445e-01, 9.19301773e-01,
9.17852346e-01, 9.12687865e-01, 9.00755102e-01,
8.77918913e-01, 8.41778780e-01, 7.97438172e-01,
7.59412209e-01, 7.43766496e-01, 7.58426057e-01],
[ 7.48028585e-01, 8.00967465e-01, 8.60639839e-01,
9.17314355e-01, 9.62374525e-01, 9.89077372e-01,
9.96239777e-01, 9.88737117e-01, 9.73767736e-01,
9.57273913e-01, 9.42647501e-01, 9.30980153e-01,
9.21800247e-01, 9.13829662e-01, 9.05516974e-01,
8.95103386e-01, 8.80063037e-01, 8.55819040e-01,
8.15680432e-01, 7.57286053e-01, 6.94667063e-01,
6.54674360e-01, 6.55242773e-01, 6.95951505e-01],
[ 5.88142228e-01, 6.56524283e-01, 7.39388262e-01,
8.26540072e-01, 9.05382649e-01, 9.63084972e-01,
9.93428420e-01, 9.99593348e-01, 9.90003898e-01,
9.72940215e-01, 9.53944608e-01, 9.35599844e-01,
9.18217361e-01, 9.00665492e-01, 8.80954002e-01,
8.56210996e-01, 8.21553193e-01, 7.67628947e-01,
6.82523479e-01, 5.74145986e-01, 4.89341942e-01,
4.69017002e-01, 5.14459717e-01, 6.05048760e-01]]
V = [[-7.64071106e-01, -7.61939824e-01, -7.56999777e-01,
fig, ax = plt.subplots(figsize=(6, 6), dpi=300);
ax.quiver(X, Y, U, V, pivot='middle');
ax.set_aspect('equal');
Output:
I've tried the above. I expect single arrows as usual.
I don't know what additional details to add to get rid of the
Didn't you ask for exactly that, repeating values 1 and 12?
#(...)
X = [[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
[ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22],
#(...)
Y = [[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1],
#(...)
U = [[ 5.91106782e-01, 6.22366562e-01, 6.49723913e-01, (...)
[ 5.77152607e-01, 5.82746773e-01, 5.76183972e-01, (...)
You even have a quadruple arrow at coordinate (1,1). Just pair X and Y, and see that X=1 Y=1 occurs 4 times! But values of U in those 4 occurences of X=1 Y=1 are all different. So those 4 arrows that starts for (1,1) are not exactly identical.
So does X=11 Y=1.
X=2 Y=1 occurs twice.
Etc.
You said "especially in the center". No, not really. It occurs on line Y=1, on column X=1, and, indeed on line Y=12 and column X=11 that both pass not far from the center.
I am trying to append values to a dictionary inside a loop, but somehow it's only appending one of the values. I recreated the setup using the same numbers I am dynamically getting.
The output from "print(vertex_id_from_shell)" is "{0: [4], 1: [12], 2: [20]}". I need to keep the keys, but add the remaining numbers to the values.
Thanks.
shells = {0: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 1: [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27], 2: [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}
uvsID = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, 1, 10, 11, 3, 12, 0, 2, 13, 14, 15, 16, 17, 17, 16, 18, 19, 19, 18, 20, 21, 21, 20, 22, 23, 15, 24, 25, 16, 26, 14, 17, 27, 28, 29, 30, 31, 31, 30, 32, 33, 33, 32, 34, 35, 35, 34, 36, 37, 29, 38, 39, 30, 40, 28, 31, 41]
vertsID = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4, 8, 9, 11, 10, 10, 11, 13, 12, 12, 13, 15, 14, 14, 15, 9, 8, 9, 15, 13, 11, 14, 8, 10, 12, 16, 17, 19, 18, 18, 19, 21, 20, 20, 21, 23, 22, 22, 23, 17, 16, 17, 23, 21, 19, 22, 16, 18, 20]
vertex_id_from_shell = {}
for shell in shells:
selection_shell = shells.get(shell)
#print(selection_shell)
for idx, item in enumerate(selection_shell):
if item in uvsID:
uv_index = uvsID.index(item)
vertex_ids = vertsID[uv_index]
vertex_id_from_shell[shell] = [ ( vertex_ids ) ]
print(vertex_id_from_shell)
#{0: [4], 1: [12], 2: [20]}
#desired result
{0: [0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 7, 0, 1, 7, 5, 6, 4], 1: [8, 9, 11, 10, 13, 12, 15, 14, 9, 8, 15, 13, 14, 12], 2: [16, 17, 19, 18, 21, 20, 23, 22, 17, 16, 23, 21, 22, 20]}
You're overwriting vertex_id_from_shell[shell] each time through the loop, not appending to it.
Use collections.defaultdict() to automatically create the dictionary elements with an empty list if necessary, then you can append.
from collections import defaultdict
vertex_id_from_shell = defaultdict(list)
for shell, selection_shell in shells.items():
for item in selection_shell:
if item in uvsID:
uv_index = uvsID.index(item)
vertex_ids = vertsID[uv_index]
vertex_id_from_shell[shell].append(vertex_ids)
You are setting vertex_id_from_shell[shell] to a new list, containing only one item every time. Instead, you should append to it.But first, of course that list needs to exist, so you should check and create it if it doesn't already exist.
shells = {0: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 1: [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27], 2: [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}
uvsID = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, 1, 10, 11, 3, 12, 0, 2, 13, 14, 15, 16, 17, 17, 16, 18, 19, 19, 18, 20, 21, 21, 20, 22, 23, 15, 24, 25, 16, 26, 14, 17, 27, 28, 29, 30, 31, 31, 30, 32, 33, 33, 32, 34, 35, 35, 34, 36, 37, 29, 38, 39, 30, 40, 28, 31, 41]
vertsID = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4, 8, 9, 11, 10, 10, 11, 13, 12, 12, 13, 15, 14, 14, 15, 9, 8, 9, 15, 13, 11, 14, 8, 10, 12, 16, 17, 19, 18, 18, 19, 21, 20, 20, 21, 23, 22, 22, 23, 17, 16, 17, 23, 21, 19, 22, 16, 18, 20]
vertex_id_from_shell = {}
for shell in shells:
selection_shell = shells.get(shell)
#print(selection_shell)
for idx, item in enumerate(selection_shell):
if item in uvsID:
uv_index = uvsID.index(item)
vertex_ids = vertsID[uv_index]
# if the list does not exist, create it
if shell not in vertex_id_from_shell:
vertex_id_from_shell[shell] = []
# append to list
vertex_id_from_shell[shell].append(vertex_ids)
print(vertex_id_from_shell)
# {0: [0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 7, 5, 6, 4],
# 1: [8, 9, 11, 10, 13, 12, 15, 14, 9, 8, 15, 13, 14, 12],
# 2: [16, 17, 19, 18, 21, 20, 23, 22, 17, 16, 23, 21, 22, 20]}
I have a random variable Words per sentence which contains those values:
words_per_sentence = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 36, 37, 38, 38, 39, 39, 40, 42, 42, 43, 43, 44, 45, 47, 48, 49, 49, 50, 50, 51, 52, 52, 54, 54, 55, 58, 62, 67, 67, 73, 80]
The observation space contains 500 values (N=500), and the mean and standard deviation are:
mu = 15.088
sigma = 12.445
I want to calculate a three-parameters-lognormal PDF for my variable and plot it in a graph but I do not get the result I want. This is my failing code up to now:
import math
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
data = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 36, 37, 38, 38, 39, 39, 40, 42, 42, 43, 43, 44, 45, 47, 48, 49, 49, 50, 50, 51, 52, 52, 54, 54, 55, 58, 62, 67, 67, 73, 80]
plt.hist(data, bins=50, color='c', alpha=0.75)
xmin = min(data)
xmax = max(data)
x = np.linspace(xmin, xmax, 200)
pdf = stats.lognorm.pdf(x, s=12.445, loc=1, scale=math.exp(15.088))
plt.plot(pdf, 'y')
The problem is that I do not get the PDF printed but a straight horizontal line in at the bottom of the graph. I cannot post any picture as I have not yet enough punctuation. Please help.
The character class you have there does not allow spaces. Add a space to it:
^[A-ZÑÁÉÍÓÚÜ ]+:
(Edited to add the Ñ that it needs)
Use
^[\p{Lu}\s]+:
See regex proof.
EXPLANATION
NODE EXPLANATION
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
[\p{Lu}\s]+ any character of: Unicode uppercase letter (\p{Lu}),
whitespace (\n, \r, \t, \f, and " ")
(1 or more times (matching the most amount possible))
--------------------------------------------------------------------------------
: ':'</pre>
If it does not work use
^[^:\r\n]+:
EXPLANATION
NODE EXPLANATION
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
[^:\r\n]+ any character except: ':', '\r' (carriage
return), '\n' (newline) (1 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
: ':'
I'm learning python and I wrote a program to pick a random office episode to watch and 75% of the time my program works but the other 25%, it gives me the error :
list index out of range.
I've tried messing with the min max values in the line that chooses the episode
import random as r
seasons = [
[1, 2, 3, 4, 5, 5, 6],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
]
def choose_ep():
global seasons
s = r.randint(1,10) # 1 - 10, not including 10
e = r.randint(min(seasons[s - 1]), max(seasons[s - 1]))
print("Season: " + str(s) + ", Episode: " + str(e))
while True:
choose_ep()
if input() == "exit":
break
I want it to give me a random episode from a random season. I don't want it to give me an episode that doesn't exist like "season 1, episode 14"
https://docs.python.org/3/library/random.html#random.randint
random.randint(a, b)
Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).
So 10 is in fact included in the values of variable s and hence you get your error.
Alternative solution with no index generation:
import random as r
season_number, episode_list = r.choice(list(enumerate(seasons)))
season_number += 1
episode_number = r.choice(episode_list)
print(season_number, episode_number)
I have the following data and after plotting scatter data point, I would like to add boxplot around each set of position. Here is my code for plotting the scatter plot:
%matplotlib inline
import matplotlib.pyplot as plt
X = [1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8,
9, 9, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 10, 10,
11, 11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 12, 12,
13, 13, 13, 13, 13, 13, 13,
14, 14, 14, 14, 14, 14, 14,
15, 15, 15, 15, 15, 15, 15]
H = [15, 17, 16, 20, 15, 18, 15,
17, 16, 16, 20, 19, 18, 15,
20, 22, 20, 22, 19, 21, 21,
19, 21, 20, 23, 21, 20, 22,
21, 23, 22, 20, 24, 22, 20,
20, 19, 20, 18, 21, 17, 19,
18, 20, 16, 15, 17, 20, 19,
19, 19, 18, 21, 21, 16, 19,
21, 22, 22, 24, 24, 23, 25,
28, 26, 30, 27, 26, 29, 30,
27, 26, 29, 31, 27, 29, 30,
25, 26, 27, 28, 25, 27, 30,
31, 28, 25, 27, 30, 25, 31,
28, 26, 30, 28, 29, 27, 31,
24, 26, 25, 28, 26, 23, 25]
fig, axes = plt.subplots(figsize=(8,5))
axes.scatter(X, H, color='b')
axes.set_xlabel('Pos');
axes.set_ylabel('H, µm');
when i add plt.boxplot, it captures all data not individual position. I appreciate the answers either in matplotlib or seaborn.
thanks
A good way would be using pandas:
df = pd.DataFrame({'X':X, 'H': H})
ax=df.plot(kind='scatter', x='X', y='H')
df.boxplot(by='X', ax=ax)
plt.show()
output:
Here's a condensed solution to how to map your H array by X and plot it using matplotlib:
groups = [[] for i in range(max(X))]
[groups[X[i]-1].append(H[i]) for i in range(len(H))]
plt.boxplot(groups)
Outcome:
you can add grid with plt.grid(True)