Re: [Scilab-users] more polarplots in one coordinate system
Hello, plot is getting smaller after margins. How to set the size of plot fixed? Tried to do it with zoom box, but this one depends on data size. Thank you :) -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035188.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Le 06/12/2016 à 14:55, Maxi041291 a écrit : Hello again, how to plot a large legend, which is next to the polarplot? If I use legend_location="in_lower_right", it is hiding my plot. If I use -"- out_lower_right, i can't see it anymore [or just the line of the box] if you put the legend out of the axes box uou may have to enlarge the corresponding margin ax=gca(); ax.margin(4)=0.25, //for the lower margin Thank you Maxi -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035183.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Hello again, how to plot a large legend, which is next to the polarplot? If I use legend_location="in_lower_right", it is hiding my plot. If I use -"- out_lower_right, i can't see it anymore [or just the line of the box] Thank you Maxi -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035183.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Please find attached a revision of the polarplot1 function wich allows to request a full 4 quadrants polar plot. and below an example with arrowed lines phase=[0;-2.8487;-2.993; 2.9664;2.8264;2.9638]; magnitude=[0;1.25e-4;2.17e-4;1.34e-4;7.5e-5;1.32e-4]; allmagnitude=[0; 1.32e-4]; allphase=[0;2.9638]; colors=[5,2,3,1,4,9]; clf for k=1:size(phase,"*")-1 polarplot1(phase(k:k+1),magnitude(k:k+1),colors(k),%t) e=gce();e.children(1).polyline_style=4; //arrowed style polylines end polarplot1(allphase,allmagnitude,colors(6),%t) e=gce();e.children(1).polyline_style=4; //arrowed style polylines or clf; phi=[];mag=[]; for k=1:size(phase,"*")-1 phi=[phi phase(k:k+1)]; mag=[mag magnitude(k:k+1)]; end phi=[phi allphase]; mag=[mag allmagnitude]; polarplot1(phi,mag,colors,%t) e=gce();e.children(1:$-1).polyline_style=4; Le 30/11/2016 à 08:27, Maxi041291 a écrit : Hello again, Its just shown the part of the polarplot, which is used, but i would like to see the plot from 0° to 360°. how do i set the angle axis from 0° to 360° every time? Thank you for helping :) -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035146.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) INRIA // Copyright (C) 2010 - DIGITEO - Manuel Juliachs // Copyright (C) 2012 - 2016 - Scilab Enterprises // // This file is hereby licensed under the terms of the GNU GPL v2.0, // pursuant to article 5.3.4 of the CeCILL v.2.1. // This file was originally licensed under the terms of the CeCILL v2.1, // and continues to be available under such terms. // For more information, see the COPYING file which you should have received // along with this program. function polarplot1(theta,rho,style,full) [lhs,rhs]=argn(0) if rhs<=0 then theta=0:.01:2*%pi; rho=sin(2*theta).*cos(2*theta) clf(); polarplot(theta,rho) return end if size(theta,1)==1 then theta=theta(:), end if size(rho,1)==1 then rho=rho(:), end if rhs<4 then full=%f;end rm=max(abs(rho)) x=rho.*cos(theta) y=rho.*sin(theta) if full then xmax=max(abs(x)); xmin=-xmax ymax=max(abs(y)); ymin=-ymax else xmin=min(x); xmax=max(x); ymin=min(y); ymax=max(y); end drawlater() a=gca(); if a.tag=="polarplot" then //clear grid delete(a.user_data.grid); bnds=a.user_data.bounds xmin=min(bnds(1),xmin) xmax=max(bnds(2),xmax) ymin=min(bnds(3),ymin) ymax=max(bnds(4),ymax) rm=max(bnds(5),rm) c=a.children g=polargrid(xmin,xmax,ymin,ymax,rm) //put the grid on the background for k=1:size(c,'*') swap_handles(c(k),g) end else polargrid(xmin,xmax,ymin,ymax,rm) end C=[] for k=1:size(theta,2) xpoly(x(:,k),y(:,k)) e=gce(); e.foreground=style(k) C=[e C]; end glue(C) drawnow() endfunction function G=polargrid(xmin,xmax,ymin,ymax,rm) // Some default values: Amin=0 // starting angle for the frame dA=360 // span of the angular frame nn=4// number of quadrants to be drawn // Angle at which Radial labels will be displayed A=round(atan((ymin+ymax)/2,(xmin+xmax)/2)/%pi*180/45)*45; dx=-0.5, dy=-0.5 // H & V shifts in string-width and string-height units L=(xmax-xmin)*1.07; H=(ymax-ymin)*1.07; //determine Qudrants to be drawn Q=[%T %T %T %T]; e=rm/500; if xmin<-e then xmin=-rm; else xmin=0; Q([2 3])=%F; end if xmax>e then xmax= rm; else xmax=0; Q([1 4])=%F; end if ymin<-e then ymin=-rm; else ymin=0; Q([3 4])=%F; end if ymax>e then ymax= rm; else ymax=0; Q([1 2])=%F; end L=(xmax-xmin)*1.1; if L==0, L=2*rm*1.1; end H=(ymax-ymin)*1.1; if H==0, H=2*rm*1.1; end x0=(xmin+xmax)/2; y0=(ymin+ymax)/2; rect=[x0-L/2 y0-H/2 x0+L/2 y0+H/2] // Special case: data aligned on the x or y axis if Q==[%F %F %F %F], if (ymax-ymin)<2*e, // on x axis if xmin<-e then Q([2 3])=%T end if xmax> e then Q([1 4])=%T end else // on y axis if ymin<-e then Q([3 4])=%T end if ymax> e then Q([1 2])=%T end end end n=find(Q); // id numbers of quadrants to be drawn nn=length(n) // number of quadrants to be drawn Amin=(n(1)-1)*90 select nn case 1, dA=90; if n==1, A=90, dx=-1.1, dy=-0.5 elseif n==2, A=90, dx=0.2, dy=-0.5 elseif n==3, A=270, dx=0.2, dy=-0.5 else A=270, dx=-1.1, dy=-0.5 end case 2 dA=180; if n(1)==1 if n(2)==2, //A=90, dx=0.1, dy=-0.5 else Amin=-90,
Re: [Scilab-users] more polarplots in one coordinate system
Hello again, Its just shown the part of the polarplot, which is used, but i would like to see the plot from 0° to 360°. how do i set the angle axis from 0° to 360° every time? Thank you for helping :) -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035146.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Sorry Serge Steer, thank you !!! That's exactly what i was looking for! -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035135.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Hey Samuel Gaugeon, i would like to have arrows in different colors. I try to show the influence of modes on the answer of my structure. In the beginning of my code iam asking how many modes the user would like to see. This is what i meant with fixed (sorry for the vocab.) what do you mean with this? "Anyway, you must call polarplot() only once. Or to convert (angles,radii) => (x, y) yourself before using plot() instead of polarplot()" Hey Tim Wescott, the problem is, that you have the same amplitude. If you zoom in, you see two different angle axis. Hey Serge Steer, i cant find a new command named polarplot1. But it would be nice if there would be one. Can i also write a string in a for loop and put it into the input of polarplot? I mean a string like: [phase(1:2) phase(2:3) phase(3:4) phase(4:5) phase(5:6) allphase],[magnitude(1:2) magnitude(2:3) magnitude(3:4) magnitude(4:5) magnitude(5:6) allmagnitude],[5,2,3,1,4,9] Is that possible? -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035134.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Please find attached a new polarplot1 function which is able to do what you want (some refinements may have to be done) Example (sequences of polar plots) phase=[0;-2.8487;-2.993; 2.9664;2.8264;2.9638]; magnitude=[0;1.25e-4;2.17e-4;1.34e-4;7.5e-5;1.32e-4]; allmagnitude=[0; 1.32e-4]; allphase=[0;2.9638]; colors=[5,2,3,1,4,9]; clf for k=1:size(phase,"*")-1 polarplot1(phase(k:k+1),magnitude(k:k+1),colors(k)) end polarplot1(allphase,allmagnitude,colors(6)) Example (many plots with a simple call) clf; phi=[];mag=[]; for k=1:size(phase,"*")-1 phi=[phi phase(k:k+1)]; mag=[mag magnitude(k:k+1)]; end phi=[phi allphase]; mag=[mag allmagnitude]; polarplot1(phi,mag,colors) Le 28/11/2016 à 16:01, Maxi041291 a écrit : Thank you for trying to help, but i think i didnt describe my Problem well enough. Normally there should be arrows in the plot, but i dont think this is possible in scilab. But here a Piece of my original code in scilab: clear; clc; phase=[0;-2.8487;-2.993; 2.9664;2.8264;2.9638]; magnitude=[0;1.25e-4;2.17e-4;1.34e-4;7.5e-5;1.32e-4]; allmagnitude=[0; 1.32e-4]; allphase=[0;2.9638]; //This is how it works, but just for a defined length of the vectors clf(1); polarplot([phase(1:2) phase(2:3) phase(3:4) phase(4:5) phase(5:6) allphase],[magnitude(1:2) magnitude(2:3) magnitude(3:4) magnitude(4:5) magnitude(5:6) allmagnitude],[5,2,3,1,4,9]); //This is the way it doesnt work clf(2); polarplot(phase,magnitude,[5,2]); polarplot(allphase,allmagnitude,[1,2]); Because the length of the vectors (Magnitude and Phase) is not fixed in my original code, i think i cant define the polarplot like its done in the first example. So i would like to do it like in the second example, but that doesn´t work, because i get a new axis for each datapoint -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035130.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) INRIA // Copyright (C) 2010 - DIGITEO - Manuel Juliachs // Copyright (C) 2012 - 2016 - Scilab Enterprises // // This file is hereby licensed under the terms of the GNU GPL v2.0, // pursuant to article 5.3.4 of the CeCILL v.2.1. // This file was originally licensed under the terms of the CeCILL v2.1, // and continues to be available under such terms. // For more information, see the COPYING file which you should have received // along with this program. function polarplot1(theta,rho,style) [lhs,rhs]=argn(0) if rhs<=0 then theta=0:.01:2*%pi; rho=sin(2*theta).*cos(2*theta) clf(); polarplot(theta,rho) return end if size(theta,1)==1 then theta=theta(:), end if size(rho,1)==1 then rho=rho(:), end rm=max(abs(rho)) x=rho.*cos(theta) y=rho.*sin(theta) xmin=min(x); xmax=max(x); ymin=min(y); ymax=max(y); drawlater() a=gca(); if a.tag=="polarplot" then //clear grid delete(a.user_data.grid); bnds=a.user_data.bounds xmin=min(bnds(1),xmin) xmax=max(bnds(2),xmax) ymin=min(bnds(3),ymin) ymax=max(bnds(4),ymax) rm=max(bnds(5),rm) end polargrid(xmin,xmax,ymin,ymax,rm) for k=1:size(theta,2) xpoly(x(:,k),y(:,k)) e=gce(); e.foreground=style(k) end drawnow() endfunction function polargrid(xmin,xmax,ymin,ymax,rm) // Some default values: Amin=0 // starting angle for the frame dA=360 // span of the angular frame nn=4// number of quadrants to be drawn // Angle at which Radial labels will be displayed A=round(atan((ymin+ymax)/2,(xmin+xmax)/2)/%pi*180/45)*45; dx=-0.5, dy=-0.5 // H & V shifts in string-width and string-height units L=(xmax-xmin)*1.07; H=(ymax-ymin)*1.07; //determine Qudrants to be drawn Q=[%T %T %T %T]; e=rm/500; if xmin<-e then xmin=-rm; else xmin=0; Q([2 3])=%F; end if xmax>e then xmax= rm; else xmax=0; Q([1 4])=%F; end if ymin<-e then ymin=-rm; else ymin=0; Q([3 4])=%F; end if ymax>e then ymax= rm; else ymax=0; Q([1 2])=%F; end L=(xmax-xmin)*1.1; if L==0, L=2*rm*1.1; end H=(ymax-ymin)*1.1; if H==0, H=2*rm*1.1; end x0=(xmin+xmax)/2; y0=(ymin+ymax)/2; rect=[x0-L/2 y0-H/2 x0+L/2 y0+H/2] // Special case: data aligned on the x or y axis if Q==[%F %F %F %F], if (ymax-ymin)<2*e, // on x axis if xmin<-e then Q([2 3])=%T end if xmax> e then Q([1 4])=%T end else // on y axis if ymin<-e then Q([3 4])=%T end if ymax> e then Q([1 2])=%T end end end n=find(Q); // id numbers of quadrants to be drawn
Re: [Scilab-users] more polarplots in one coordinate system
Le 28/11/2016 16:01, Maxi041291 a écrit : Thank you for trying to help, but i think i didnt describe my Problem well enough. Normally there should be arrows in the plot, You did not require this previously. but i dont think this is possible in scilab. https://help.scilab.org/docs/6.0.0/en_US/polyline_properties.html But here a Piece of my original code in scilab: clear; clc; phase=[0;-2.8487;-2.993; 2.9664;2.8264;2.9638]; magnitude=[0;1.25e-4;2.17e-4;1.34e-4;7.5e-5;1.32e-4]; allmagnitude=[0; 1.32e-4]; allphase=[0;2.9638]; //This is how it works, but just for a defined length of the vectors clf(1); polarplot([phase(1:2) phase(2:3) phase(3:4) phase(4:5) phase(5:6) allphase],[magnitude(1:2) magnitude(2:3) magnitude(3:4) magnitude(4:5) magnitude(5:6) allmagnitude],[5,2,3,1,4,9]); Sorry, i don't understand what you wish: Do you really wish to have each segment one by one with a different color? //This is the way it doesnt work clf(2); polarplot(phase,magnitude,[5,2]); polarplot(allphase,allmagnitude,[1,2]); Anyway, you must call polarplot() only once. Or to convert (angles,radii) => (x, y) yourself before using plot() instead of polarplot() Because the length of the vectors (Magnitude and Phase) is not fixed in my original code, What do you mean by "is not fixed"? i think i cant define the polarplot like its done in the first example. So i would like to do it like in the second example, but that doesn´t work, because i get a new axis for each datapoint With polarplot, presently you can't avoid it. Each call yields a polar frame. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Thank you for trying to help, but i think i didnt describe my Problem well enough. Normally there should be arrows in the plot, but i dont think this is possible in scilab. But here a Piece of my original code in scilab: clear; clc; phase=[0;-2.8487;-2.993; 2.9664;2.8264;2.9638]; magnitude=[0;1.25e-4;2.17e-4;1.34e-4;7.5e-5;1.32e-4]; allmagnitude=[0; 1.32e-4]; allphase=[0;2.9638]; //This is how it works, but just for a defined length of the vectors clf(1); polarplot([phase(1:2) phase(2:3) phase(3:4) phase(4:5) phase(5:6) allphase],[magnitude(1:2) magnitude(2:3) magnitude(3:4) magnitude(4:5) magnitude(5:6) allmagnitude],[5,2,3,1,4,9]); //This is the way it doesnt work clf(2); polarplot(phase,magnitude,[5,2]); polarplot(allphase,allmagnitude,[1,2]); Because the length of the vectors (Magnitude and Phase) is not fixed in my original code, i think i cant define the polarplot like its done in the first example. So i would like to do it like in the second example, but that doesn´t work, because i get a new axis for each datapoint -- View this message in context: http://mailinglists.scilab.org/more-polarplots-in-one-coordinate-system-tp4035127p4035130.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] more polarplots in one coordinate system
Hello Le 28/11/2016 11:12, Maxi041291 a écrit : Hello together, i would like two plot a few polarplots in one coordinate-system. The number of the plots should be defined by the length of a vector. In Matlab i would use the hold on command in a for Loop for it. I know, that i dont Need the hold on command in the plot(), but if i define two polarplots, i get two different coordinate Systems. For e.g. polarplot(Phase,magnitude) polarplot(Phase1, magnitude1) I have to define those in one polarplot to get one coordinate System for both: polarplot([Phase phase1],[Magnitude,magnitude1]). Now my question is: how can i automatically define more polarplots (depending on the length of my vectors) in one coordinate System? If i understand well: you have several curves having different numbers of points, and you want to plot all of them on the same polarplot? The only way i see presently to do that is * to get the size of the longest vector * to padd all other ones with %nan values * finally to send the matrix of all concatenated vectors -- one column per curve Example: longest = 100; // maximal number of points nc = 2; // number of curves theta = zeros(longest, nc) + %nan; r = theta; // Curve #1 i = 1; tmp = 0:75; theta(1:length(tmp),i) = tmp; r(1:length(tmp),i) = sind(2*tmp); // Curve #2 i = 2; tmp = 45:135; theta(1:length(tmp),i) = tmp; r(1:length(tmp),i) = cosd(5*tmp); // Display polarplot(theta/180*%pi, r) HTH Samuel Gougeon ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users