[scilab-Users] heatmap / Matplot

Mathieu Dubois mathieu.dubois at limsi.fr
Mon Jun 9 20:28:40 CEST 2008


Hello Joshua, Hello scilabers,

Joshua Auerbach a écrit :
> Thanks for the info on grayplot.  A little confusing that something 
> that plots colors would be called "gray"plot don't you think?
This came to my mind when I was writing you ;)
>
> In any case, this almost gets me to where I want, except grayplot 
> determines the color for each rectangle from the average value at each 
> corner and I do not want this.  I want each rectangle to only take its 
> color from one value (what is at the center of the rectangle).  ie if 
> my z matrix is binary I want to only see two colors but with grayplot 
> i will get a color for 0 (all four corners 0), 0.25 (one corner 1), 
> 0.5 (two corners 1), 0.75 (three corners 1) and 1 (all four corners 1).
>
> Any advice on how to do that?
Maybe.

You can choose the number of colors in the colormap. If you use 
graycolormap(2) you will have one color for '0' and one for '1' (if you 
have N discrete values, graycolormap(N) works). See the script. I am not 
completely satisfied with this so if somebody have a better idea let me 
know.

The more general way would be to paint the rectangle [(x(i), y(j)), 
(x(i+1), y(j+1))] with the right color. I don't know enough for that. 
Scilab graphics are rather complex.
>
> Thanks,
> Josh
Thanks for the question,
Mathieu
>
> duboism at limsi.fr wrote:
>> Hi Joshua,
>>
>> I think that the function grayplot (and its friends fgrayplot, 
>> Sgrayplot)
>> would be useful for you but you will have to reformat your data.
>>
>> grayplot takes 3 arguments: x (vector of x coordinates, size nx), y
>> (vector of y coordinates, size ny) and a nx*ny matrix data (the value at
>> data(i,j) is the value of point (x(i), y(j)) ). See the script
>> test_grayplot.sce.
>>
>> It should not be hard to re-format your data this way.
>>
>> Note the use of the zminmax option to plot different data with the same
>> color scale (see test_grayplot2.sce).
>> Note also that on the x86_64 architecture the function colorbar seems
>> broken (in fact you cannot use it since it raises an error).
>>
>> Mathieu
>>
>>  
>>> Hi,
>>>
>>> I am looking for some assistance.  I am trying to make what I know as a
>>> heatmap.  Basically I have data for many points on a grid and want to
>>> construct a 2d plot where each point is given a color on a gradient
>>> (From blue to red say) based on the data value at that point.  I have
>>> the data in the form of a matrix with 3 columns x-coord, y-coord, data
>>> value
>>>
>>> Currently I am making this type of plot by transforming my grid
>>> coordinates into matrix coordinates of a new matrix and scaling my data
>>> values into the range [0, NUM_COLORS] and using the Matplot function to
>>> plot this data.  This method does work, but has a few shortcomings: I
>>> lose the original scale of my grid since the axis labels are based on
>>> the matrix coordinates.  There is no key explaining the gradient and
>>> even if there were I would lose the original scale of my data values.
>>>
>>> Does anyone know how to get around these limitations or know of a 
>>> better
>>> way to accomplish what I am trying to do?  I'd appreciate any help.
>>>
>>> Cheers,
>>> Josh
>>>
>>>     
>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_grayplot_binary.sce
URL: <https://lists.scilab.org/pipermail/users/attachments/20080609/becd59e2/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_grayplot_n.sce
URL: <https://lists.scilab.org/pipermail/users/attachments/20080609/becd59e2/attachment-0001.ksh>


More information about the users mailing list