#!/usr/bin/env python3fromsympyimport symbols, plot, Rational
print('14.')
x = symbols('x')
ys = [x **2-4* x +7,
4* x **2+12* x +9,
x * (4-3* x) /2]
ys0 = [3, 0, Rational(2, 3)]
p = plot(*ys, *ys0,
(x, -10, 10),
ylim=(-10, 10),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
for o, color inzip(p, colors):
o.line_color = color
p.show()
p.save('sample14.png')
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample14.py
14.
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1065: MatplotlibDeprecationWarning:
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
self.ax[i].spines['left'].set_smart_bounds(True)
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1066: MatplotlibDeprecationWarning:
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
self.ax[i].spines['bottom'].set_smart_bounds(False)
%
0 コメント:
コメントを投稿