Python Forum
Porting a MATLAB program into Python? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Porting a MATLAB program into Python? (/thread-1292.html)



Porting a MATLAB program into Python? - xpress_embedo - Dec-21-2016

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

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);
end
and 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()



RE: Porting a MATLAB program into Python? - micseydel - Jan-16-2017

I'm afraid we don't have any matplotlib specialists here. You might try a more dedicated forum - http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
I can't vouch for the quality of that forum (and in fact I was reluctant to recommend it since there's spam from three days ago) but thought this would be better than not replying at all; feel free to let us know if you had any luck or not there.