Dec-21-2016, 06:44 AM
Hello! Everyone,
I am new to Python and i have to port a program written in MATLAB into Python, this program uses plot and that's why i had installed matplotlib, most of the things are working properly, but i stuck with the following MATLAB function.
MATLAB Function
I need this function in Python.
The MATLAB code is as follow:
I am new to Python and i have to port a program written in MATLAB into Python, this program uses plot and that's why i had installed matplotlib, most of the things are working properly, but i stuck with the following MATLAB function.
MATLAB Function
h = plot(___)returns a column vector of chart line objects. Use h to modify properties of a specific chart line after it is created. For a list of properties, see Chart Line Properties.
I need this function in Python.
The MATLAB code is as follow:
for i=1:180 hold on; [x, y] = pol2cart(i*0.0174532925, 100); h(i) = plot([0,x],[0,y],'g','LineWidth',1); endand later this h(i) is used as follow in MATLAB code.
set(h(th),'color','r'); [x0, y0] = pol2cart(th*0.0174532925, 100); [x, y] = pol2cart(th*0.0174532925, r); set(h(th),'XData',[x0,x]); set(h(th),'YData',[y0,y]); m = plot([0,x0],[0,y0],'r','LineWidth',3);My Python Program is as follow:
for i in range(1,181): [x,y] = pol2cart(i*math.pi/180, MAX_DIST) h = ax.plot([0,x], [0,y],color='green')and
[x0, y0] = pol2cart(theta*math.pi/180, MAX_DIST) [x, y] = pol2cart(theta*math.pi/180, distance) m = ax.plot([0,x0], [0,y0],color='red', linewidth=3.0) ax.plot([x0,x], [y0,y],color='blue') plt.pause(PAUSE) m.pop(0).remove()