0
votes

I have several arrays for which I calculate the Frobenius norm. Then I simply draw a graph of these calculated norms vs the index of their corresponding arrays. The problem is that when the plot window pops out, there is no graph on it. But, when I add a styling for my plot, it shows the graph. I also tried to use save figure, but the saved figure just shows a window without any graph on it. The last thing that I tried was to print out the array of the calculated norms, defining it as a numpy array and draw it vs the array of the corresponding indices and it shows me the graph! So, my question is why I cannot draw the graph with pylot plot function. This is what I get when I print out the array of calculated norms:

FrobNorm=[[ -3.27415727e-01   2.83421670e+00  -2.59669415e+00  -3.83713705e+00
   -1.11064367e+00  -9.83842479e+00   9.64202990e+00  -3.66747069e+00
    9.49022713e+00  -3.58659316e+00   4.28355911e+00  -4.58104577e+00
   -4.26765959e+00  -6.54306600e-01   4.31816208e+00   1.08043604e+01
    3.36647201e+01  -9.47369163e+00   1.41183067e+01   1.75464238e+00
    6.84732164e+00  -1.13034176e+01  -1.83641151e+01  -6.07528575e+01
   -2.11765783e+01  -3.46253416e+01  -3.50911001e+01  -1.78855570e+01
    2.00630855e+01   1.90068192e+01   3.33858144e-01  -1.75526132e+01
   -1.34355117e+01  -8.39318642e+00  -1.96338714e+01  -5.80396650e+01
   -1.52712614e+01  -7.95109842e+00  -1.14383666e+01  -4.29497153e+00
   -1.97874688e+01  -1.32635215e+01   3.10595354e+00   3.30488466e-01
    1.24957569e+00   2.32608957e+01  -5.12962561e-01   3.23879652e+00
    1.80536181e+01   1.64091731e+01   2.46815567e+01   2.01190758e+01
    2.25210602e+01   1.92789009e+01   4.32809711e+01   1.24060317e+02
    5.11700004e+00   2.56249967e+00   3.27317719e+01   3.01294858e+01
    2.96865339e+01   2.01666494e+01  -1.75473758e+00  -9.73091969e+00
   -1.51961382e+01   8.11369952e+00  -1.74469244e+01   5.94097932e+00
   -5.43142631e+00  -4.40072150e+00  -1.51168549e+01  -5.58957352e+00
   -2.34872324e+04   9.19836593e+02   6.76833045e+03   7.59304882e+03
    1.77573454e+03   9.71109062e+02   1.63742243e+03   3.70221807e+02
    1.01405251e+03   4.06811235e+02   1.45049823e+02   1.43212472e+02
    8.88928849e+01   3.10859242e+02   4.79435420e+01   6.86347162e+01
    2.14372829e+01   5.43555421e+01   1.39810283e+01   9.51714116e+00
    4.98563968e+01   4.02058896e+01   1.61359027e+02   7.91939932e+00
    1.73949723e+01   5.19412047e+01   1.89645369e+01   2.25526021e+01
    1.36734416e+01   3.13646035e+01   2.02633125e+01   5.16259077e+01
    7.34024536e+01   2.01376746e+01   8.50796026e+00   1.76689397e+01
    5.32159344e+01   1.75182361e+01   2.38797434e+01   2.21623152e+01
    2.15496171e+01   1.56287225e+01   7.12160153e+01   1.20319418e+01
   -2.14376043e-01  -2.16844613e+00   7.31383577e+00   9.60358643e+00
   1.53346738e+01  -1.75376507e+01  -4.23607412e+01  -1.34004685e+01
  -5.74096286e+01  -1.88056408e+01   1.24411854e+00  -2.20228598e+00
  -1.44691587e+01  -4.02906454e+00  -7.06859151e+00  -9.28329296e-01
   3.97785623e+00  -1.17290825e+01   5.30538782e+00  -1.30573008e+00
   2.57332085e-01  -5.03652416e+00  -8.01889243e+00  -4.21210481e+00
   7.97575488e+00   1.33063141e+01   1.94559898e+01   1.30643051e+01
   1.39963350e+00   1.31746057e+01   4.87291463e-01   7.62221548e+00
   1.90832548e+00  -9.17783469e+00  -6.74190235e+00  -5.18322407e+00
   2.08694160e+00  -8.32251763e+00  -3.41052019e+01  -4.07077413e+00
  -5.35572194e+00  -1.00300755e+01  -1.85180723e+00  -2.85137343e+00
  -2.92087149e+00   5.82955457e+00   4.00575111e+00   1.17418771e+01
   2.13152055e+01   6.74130687e+00   2.89890044e+00   9.56403257e+00
   9.49920338e+00  -4.90698086e+00  -4.31125932e-01   7.43422603e+00
  -1.36522668e+00   6.71239870e+00   2.97819245e+01   2.70232682e+00
   1.43525496e+01   7.69774164e-01   6.11231825e+00   1.48208154e+00
  -2.23136432e+00   4.61075719e+00  -3.59137897e+01  -1.62455157e+01
  -6.07367620e+01  -2.62556836e+00  -1.64717047e-01  -1.33588774e+01
  -8.23873116e+00  -4.69412397e+00  -8.64679071e+00  -7.05601974e+00
   9.42962930e+00  -1.08717341e+01  -5.27810809e+01  -8.69225245e+00
  -4.99076301e+00]]

When I plot the graph vs its indices array, I only get the window with no graph:

plt.plot(numVec,FrobNorm)
plt.show()

enter image description here

But, when I use a styling for the plot it shows the graph (something like scatter plot, which I am not interested in):

plt.plot(numVec,FrobNorm,'ro')
plt.show()

enter image description here

Now, I print the array of calculated norms. comma separate it, and define a numpy array with its elements and simply draw the graph of this numpy array and the corresponding array of indices and I get:

enter image description here

I want to get the same thing in the first place. My question is why I cannot get any graph when I plot the calculated norms. As, I said I am not looking for the scatter graph, like in the second figure, which surprisingly is something that I can get only by changing the styling of the figure.

1
why are you using double bracket for ForbNorm ? - obchardon
I am not using double bracket, this is how it looks like when I print it. - Miranda
What is the shape of numVec? - Paul Brodersen
It is (1L, 197L), the same as the shape of FrobNorm. - Miranda
Lol, I think I got it. Are you saving the image as a png or a jpg? Try saving the image as a pdf or a svg. - Paul Brodersen

1 Answers

0
votes

I think I got it. I used squeeze and it works. So, the plot line should be changed like this:

plt.plot(np.squeeze(NumVec),np.squeeze(FrobNorm))

I still don't understand why, but this is what I guess; I think somehow the format of the numpy arrays that were produced, was in the way that plot function could only see the range of the values without having access to every single element of the arrays. When I didn't use the squeeze function, I got the window without the plot, but the range of the x and y axis were the same as when I could draw the plot in the second and third figures. This is only a guess, I hope someone could help me with the real reason. Thank you for all the feedback!