I am indulging with Python and wanted to see the output of the function's graphs using the string interpreter in the code, but when I try to output several functions, it simultaneously displays nonsense, I will be grateful for the hint in which I am
import matplotlib.pyplot as plt import numpy as np import math as m def GenByPars(Params,ErrorFit,Startp,Lastp,Iteration,Funct): if (isinstance(Params, str)==False) | (isinstance(Funct, str)==False): print('Параметеры Params & Funct это ебать только строка') return 0 StringEx = ''; G=Params.find(";") while (G!=-1): StringEx = Params[: Params.find(";")] exec(StringEx) Params = Params[ Params.find(";") + 1 : ] G = Params.find(";") ArrF = np.array(['print(Ok)']) Index=0; Test = Funct G=Test.find(";") StringEx = ''; while (G!=-1): StringEx = Test[: Test.find(";")] ArrF = np.append([StringEx],ArrF) Test = Test[ Test.find(";") + 1 : ] Index+=1 G = Test.find(";") XCordA = np.empty((Index,Iteration)) Y = XCordA i=0 while (i!=Index): XCordA[i] = np.linspace(Startp, Lastp, Iteration, True) print(ArrF[i]) Y[i] = eval(ArrF[i]) i+=1 LX = np.ravel(XCordA) LY = np.ravel(Y) for i in range(0,len(Y)): LY[i] = LY[i] + np.random.uniform(-ErrorFit,ErrorFit) # Тут твой рандом Result = np.array([LX, LY]) return Result Coords = GenByPars('a=10;b=-3;',0,0,100,500,'a*np.sin(XCordA[i]/(2*np.pi))+b;a*np.cos(XCordA[i]/(2*np.pi))+b*10;') plt.plot(Coords[0], Coords[1],'*') plt.show()
x
coordinates + a set ofy
coordinates, or just a set ofy
coordinates, taking an array of indices asx
(as stated in the documentation). So he draws youCoords[0]
asx
, andCoords[1]
- asy
Therefore, use the separate plt.plot commands to output each chart - strawdog