[Scilab-users] Sgrayplot/champ for non-regular grids

Samuel Gougeon sgougeon at free.fr
Tue Apr 16 16:49:16 CEST 2019


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





More information about the users mailing list