Forum Archive

Bug in Matplotlib?

ihf

I took this script from a matplotlib tutorial. It crashes Pythonista (latest beta) on an iPad Pro.

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2, 100)

plt.plot(x, x, label='linear')
plt.plot(x, x2, label='quadratic')
plt.plot(x, x
3, label='cubic')

plt.xlabel('x label')
plt.ylabel('y label')

plt.title("Simple Plot")

plt.legend()

plt.show()

cvp

@ihf typing error, code is

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2, 100)

plt.plot(x, x, label='linear')
plt.plot(x, x**2, label='quadratic')
plt.plot(x, x**3, label='cubic')

plt.xlabel('x label')
plt.ylabel('y label')

plt.title("Simple Plot")

plt.legend()

plt.show()

see here

ihf

@cvp I guess the double ** is treated as a formatter. In any case, the script crashes Pythonista.

cvp

@ihf I don't have any problem

ihf

Yes that is what it should look :-) It crashes Pythonista immediately on my iPad running the current beta. Is that what you are running?

cvp

@ihf You are right: if I force a run in Python 2.7, it crashes

Fatal Python error: Aborted

Thread 0x000000016f2e3000 (most recent call first):
ihf

Yet another reason to run 3.6 rather than 2.7. BTW, where did you find the error msg? Is there a crash log?

cvp

@ihf pythonista_startup from @dgelessus see here

omz

I apologize for this bug, this is in no way meant to force anyone to upgrade to 3.6, but I'd seriously recommend that you get on board with Python 3 quite soon, as it'll ensure that your code will continue to run without problems in the future.

I don't think that I'll remove Python 2.7 support from Pythonista in the near future, but a lot of new features require Python 3 already.

mikael

Also, now less than a year until Python 2 becomes unsupported by core developers, so no reason to build anything new on it.