Philippe Roux |
hi to all,
I realized that scilab function "Sgrayplot" (and other 2D plotting functions like "champ") only accept "regular grids" that is Sgrayplot(X,Y,Z) requires size(Z)=length(X)xlength(Y) while "surf" also accept non-regular ones with size(Z)=size(X)=size(Y) this pose substantial problems in some plots, compared to matlab/octave behaviors, and it would be a nice feature that Sgrayplot and others accept non-regular grid in the same way as "surf". My problem started when I needed to plot a vector field "above" a gray plot, the usual way to do this is straight and simple : dt=0.1;t=-1:dt:1; [X,Y]=meshgrid(t,t); Z=X.^2-Y.^2;// potential field Vx=X;Vy=Y;//vector field clf; Sgrayplot(t,t,Z') champ(t,t,Vx',Vy')// simple ... except the ' on Z,Vx,Vy :-) but I need to do this for Z,Vx,Vy corresponding to a non-regular grid (It comes from a Joukowski transform for those who want to know) so I can't use anymore Sgrayplot/champ and I try to replace them with surf/xarrows dt=0.1;t=-1:dt:1; [X,Y]=meshgrid(t,t);// <== in real life X,Y are non-regular Z=X.^2-Y.^2;// potential field Vx=X;Vy=Y;//vector field clf; // let's try to simulate Sgrayplot surf(X,Y,Z);E=gce();E.thickness=0;E.color_flag=3; A=gca();A.rotation_angles=[0,90]; // horrible hack to replace "champ" xarrows([X(:)';X(:)'+dt*Vx(:)'],[Y(:)';Y(:)'+dt*Vy(:)'],[Z(:)';dt+Z(:)'],1) If you compare both plot the second method isn't satisfying, because vectors can be hidden by the surface (and code is complex!). Can someone provide a work-arround to improve the result since changing the specification of Sgrayplot/champ can't be done quickly. sincerely yours, Philippe _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Christophe Dang Ngoc Chan |
Hello Philippe,
> De : philippe > Envoyé : mardi 16 avril 2019 15:32 > > I realized that scilab function "Sgrayplot" (and other 2D plotting functions like > "champ") only accept "regular grids > [...] > but I need to do this for Z,Vx,Vy corresponding to a non-regular > [...] > Can someone provide a work-arround to improve the result since changing > the specification of Sgrayplot/champ can't be done quickly. Just a quick idea: have you considered using interp2d() or linear_interpn() to get values on a regular grid? HTH, regards -- Christophe Dang Ngoc Chan Mechanical calculation engineer General This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Samuel GOUGEON |
In reply to this post by Philippe Roux
Hello Philippe,
Le 16/04/2019 à 15:31, philippe a écrit : > hi to all, > > I realized that scilab function "Sgrayplot" (and other 2D plotting > functions like "champ") only accept "regular grids" that is > Sgrayplot(X,Y,Z) requires > > size(Z)=length(X)xlength(Y) > > while "surf" also accept non-regular ones with > > size(Z)=size(X)=size(Y) > > this pose substantial problems in some plots, compared to matlab/octave > behaviors, and it would be a nice feature that Sgrayplot and others > accept non-regular grid in the same way as "surf". > > My problem started when I needed to plot a vector field "above" a gray > plot, the usual way to do this is straight and simple : > > dt=0.1;t=-1:dt:1; > [X,Y]=meshgrid(t,t); > Z=X.^2-Y.^2;// potential field > Vx=X;Vy=Y;//vector field > clf; > Sgrayplot(t,t,Z') > champ(t,t,Vx',Vy')// simple ... except the ' on Z,Vx,Vy :-) > > but I need to do this for Z,Vx,Vy corresponding to a non-regular grid > (It comes from a Joukowski transform for those who want to know) so I > can't use anymore Sgrayplot/champ and I try to replace them with > surf/xarrows > > dt=0.1;t=-1:dt:1; > [X,Y]=meshgrid(t,t);// <== in real life X,Y are non-regular > Z=X.^2-Y.^2;// potential field > Vx=X;Vy=Y;//vector field > clf; > // let's try to simulate Sgrayplot > surf(X,Y,Z);E=gce();E.thickness=0;E.color_flag=3; > A=gca();A.rotation_angles=[0,90]; > // horrible hack to replace "champ" > xarrows([X(:)';X(:)'+dt*Vx(:)'],[Y(:)';Y(:)'+dt*Vy(:)'],[Z(:)';dt+Z(:)'],1) > > If you compare both plot the second method isn't satisfying, because > vectors can be hidden by the surface (and code is complex!). > > Can someone provide a work-arround to improve the result since changing > the specification of Sgrayplot/champ can't be done quickly. Have you tried fec()? As with plot3d() (seen from gca().rotation_angles(1)=0), isn't colors interpolation the same as smoothing? HTH Samuel _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Philippe Roux |
In reply to this post by Christophe Dang Ngoc Chan
Le 16/04/2019 à 16:16, Dang Ngoc Chan, Christophe a écrit :
> > Just a quick idea: > have you considered using interp2d() at first look yes but interp2d() use the output of spline2d(x,y,z) where x and y should be vectors which is a "regular grid" .... After a Joukowski transform the regular grid is transformed like this : https://photos.app.goo.gl/1rqWtyhYUCaofrme6 > or linear_interpn() to get values on a regular grid? looks like I search for the reverse function ! tanks for your reply, Philippe _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Philippe Roux |
In reply to this post by Samuel GOUGEON
Le 16/04/2019 à 16:49, Samuel Gougeon a écrit :
> > > Have you tried fec()? It looks promising to replace surf in my problem, but is there an easy way to convert meshgrid output to a triangulation? > As with plot3d() (seen from gca().rotation_angles(1)=0), > isn't colors interpolation the same as smoothing? I think yes , at least as final rendering. Cheers Philippe _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
In reply to this post by Philippe Roux
What about cshep2d and eval_cshep2d? This seems not to need grided dta. Federico Miyara On 16/04/2019 14:33, philippe wrote:
Le 16/04/2019 à 16:16, Dang Ngoc Chan, Christophe a écrit :Just a quick idea: have you considered using interp2d()at first look yes but interp2d() use the output of spline2d(x,y,z) where x and y should be vectors which is a "regular grid" .... After a Joukowski transform the regular grid is transformed like this : https://photos.app.goo.gl/1rqWtyhYUCaofrme6or linear_interpn() to get values on a regular grid?looks like I search for the reverse function ! tanks for your reply, Philippe _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Christophe Dang Ngoc Chan |
In reply to this post by Philippe Roux
Hello Philippe,
> Apr 16, 2019; 7:45pm Philippe Roux > > but is there an easy > way to convert meshgrid output to a triangulation? For this, you might try the Delaunay triangulation. You can find it in the CGLAB Atoms module https://www.scilab.org/tutorials/introduction-model-reduction https://atoms.scilab.org/toolboxes/cglab/2.3.2 HTH, Regards -- Christophe Dang Ngoc Chan Mechanical calculation engineer General This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Free forum by Nabble | Edit this page |