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
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:
and later this h(i) is used as follow in MATLAB code.
My Python Program is as follow:
and
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
1 |
h = plot(___) |
I need this function in Python.
The MATLAB code is as follow:
1 2 3 4 5 |
for i = 1 : 180 hold on; [x, y] = pol2cart(i * 0.0174532925 , 100 ); h(i) = plot([ 0 ,x],[ 0 ,y], 'g' , 'LineWidth' , 1 ); end |
1 2 3 4 5 6 |
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 ); |
1 2 3 |
for i in range ( 1 , 181 ): [x,y] = pol2cart(i * math.pi / 180 , MAX_DIST) h = ax.plot([ 0 ,x], [ 0 ,y],color = 'green' ) |
1 2 3 4 5 6 7 |
[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() |