[Scilab-users] ?==?utf-8?q? grayplot - colorbar

Antoine Monmayrant amonmayr at laas.fr
Thu Nov 24 14:20:45 CET 2016


Le Jeudi, Novembre 24, 2016 13:01 CET, SCHULZ Wolfgang <W.Schulz at ove.at> a écrit: 
 
> Hi Rafael,
> wow - thanks a lot. This is exactly what I need.
> Thanks also to Samuel for his answer.
> 
> For my understanding: I do not understand why you have to scale the matrix and also how to scale. Could you explain what you are doing?

Your matrix as to extend in values from 1 to Nc where Nc is the number of colors in your colormap.
Here is an example to illustrate it:

h=scf();
nc=128;
h.color_map=hotcolormap(nc);
mymatrix=rand(50,60);
mymatrix_scaled=(mymatrix-min(mymatrix))/(max(mymatrix)-min(mymatrix))*(nc-1)+1;

Matplot(mymatrix_scaled) // nice black-red-yellow-white plot as the matrix extends from 1 to nc
//Matplot(mymatrix) // the whole plot is black as mymatrix<=1

If you uncomment the last line, you'll see that the matrix is all black because its range of value is not 1:nc.

Cheers,

Antoine


> Mcol = 1+(Nc-1)*(M-z1)/(z2-z1); // scale data to colors indexes
> 
> Further:
> - I have problems displaying a grid in the plot. It seems the standard function (xgrid) and also with the property of the figure it doesn't work.
> - Something strange is also the axis label - it is displayed inside the axis. Is there an easy way to change this except a.x_label.position?
> 
> Thanks a lot
> Wolfgang
> 
> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: users [mailto:users-bounces at lists.scilab.org] Im Auftrag von Rafael
> > Guerra
> > Gesendet: Mittwoch, 23. November 2016 18:07
> > An: Users mailing list for Scilab
> > Betreff: Re: [Scilab-users] grayplot - colorbar
> > 
> > Hi Wolfgang,
> > 
> > Please check the code below using Matplot1() function.
> > It was not easy to write proper code, as the help file is relatively poor for the
> > Matplot1 function.
> > 
> > // START OF CODE
> > // plot a matrix with Matplot1
> > clf()
> > Nc= 128;   // number of colors
> > dxp=0:5:10;
> > dyp=0:5:10;
> > x1=min(dxp);
> > y1=min(dyp);
> > M= [64 30 2; 4 5 6; 7 8 33]  // M can have any real numbers
> > z1 = min(M);
> > z2 = max(M);
> > Mcol = 1+(Nc-1)*(M-z1)/(z2-z1); // scale data to colors indexes ax = gca();//get
> > current axes handle ax.data_bounds = [min(dxp),min(dyp); max(dxp),max(dyp)];
> > //set the data_bounds Matplot1(Mcol,[min(dxp),min(dyp), max(dxp),max(dyp)])
> > drawaxis(x=dxp,y=y1,dir='d',tics='v')
> > drawaxis(x=x1,y=dyp,dir='l',tics='v')
> > f = gcf();
> > f.color_map = jetcolormap(Nc);
> > colorbar(z1,z2,[1 Nc]);
> > // END OF CODE
> > 
> > 
> > Regards,
> > Rafael
> > 
> > -----Original Message-----
> > From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of SCHULZ
> > Wolfgang
> > Sent: Wednesday, November 23, 2016 4:05 PM
> > To: Users mailing list for Scilab <users at lists.scilab.org>
> > Subject: [Scilab-users] grayplot - colorbar
> > 
> > Hello,
> > I'm using Scilab 6 beta 2 under Win 10 and I have a problem with grayplot and
> > a colorbar.
> > 
> > With the following script I would expect to have at least 1 square colored in red
> > because I scale the colorbar to the maximum of the matrix but with grayplot it
> > doesn't work:
> > 
> > map = jetcolormap(64);
> > f=get("current_figure");
> > f.color_map = map;
> > dxp=0:5:10;
> > dyp=0:5:10;
> > nb_xy=[64 30 2; 4 5 6; 7 8 33]
> > colorbar(1,max(nb_xy),[1 64]);
> > grayplot(dxp,dyp,nb_xy)
> > 
> > Using Sgrayplot shows 1 corner in red but in this case I cannot see the
> > individual grid cells what is absolutely necessary for me.
> > 
> > What can I do? What is my mistake?
> > Thanks for your help.
> > Wolfgang
> > 
> > _______________________________________________
> > users mailing list
> > users at lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
> > _______________________________________________
> > users mailing list
> > users at lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>




More information about the users mailing list