pythonの関数をグラフに出力をする

実現したいこと

pythonの関数をmatplotlibに出力をしたい

前提

pythonの関数についての初歩的な勉強

発生している問題・エラーメッセージ

エラーメッセージ ```RecursionError Traceback (most recent call last) <ipython-input-8-49a7286b7a0a> in <cell line: 10>() 8 return func(x,a,b) 9 ---> 10 plt.plot(x,func(x,a,b)) 11 plt.show() 1 frames ... last 1 frames repeated, from the frame below ... <ipython-input-8-49a7286b7a0a> in func(x, a, b) 6 def func(x,a,b): 7 y=a*x+b ----> 8 return func(x,a,b) 9 10 plt.plot(x,func(x,a,b)) RecursionError: maximum recursion depth exceeded ### 該当のソースコード ```Python ソースコード

import numpy as np
import matplotlib.pyplot as plt

x=np.arange(0,11,1)
a=1;b=2
def func(x,a,b):
y=a*x+b
return func(x,a,b)

plt.plot(x,func(x,a,b))
plt.show()

試したこと

plt.plot()の()内を(x, func(x,a,b))ではなく(x,y)とした

補足情報(FW/ツールのバージョンなど)

google colabを使用

コメントを投稿

0 コメント