color coding for numbers

Discussion in 'Python' started by namenobodywants@gmail.com, Aug 21, 2012.

  1. Guest

    hello

    what is the best way of using color/shading on a tkinter canvas as a visualization for a two-dimensional grid of numbers? so far my best idea is to use the same value for R,G and B (fill = '#xyxyxy'), which gives shades of gray. if possible i'd like to have a larger number of visually distinct values. i've seen visualizations that seem to use some kind of hot-versus-coldcolor coding. does anybody know how to do this? thanks if you can help.

    peace
    stm
     
    , Aug 21, 2012
    #1
    1. Advertising

  2. Am 21.08.2012 10:38, schrieb :
    > what is the best way


    Define "best" before asking such questions. ;)


    > using color/shading on a tkinter canvas as a visualization for a
    > two-dimensional grid of numbers? so far my best idea is to use the
    > same value for R,G and B (fill = '#xyxyxy'), which gives shades of
    > gray. if possible i'd like to have a larger number of visually
    > distinct values.


    The basic idea behind this is that you first normalize the values to a
    value between zero and one and then use that to look up an according
    color in an array. Of course you can also do both in one step or compute
    the colors in the array on the fly (like you did), but it helps keeping
    things simple at least for a start, and it also allows testing different
    approaches separately.

    If the different number of resulting colors isn't good enough then, it
    could be that the array is too small (its size determines the maximum
    number of different colours), that the normalization only uses a small
    range between zero and one (reducing the effectively used number of
    colours) or simply that your screen doesn't support that many different
    colors.


    > i've seen visualizations that seem to use some kind
    > of hot-versus-cold color coding. does anybody know how to do this?


    The colour-coding is just the way that above mentioned array is filled.
    For the hot/cold coding, you could define a dark blue for low values and
    a bright red for high values and then simply interpolate the RGB triple
    for values in between.

    Uli
     
    Ulrich Eckhardt, Aug 21, 2012
    #2
    1. Advertising

  3. DJC Guest

    On 21/08/12 12:55, Ulrich Eckhardt wrote:
    > Am 21.08.2012 10:38, schrieb :
    >> what is the best way

    >
    > Define "best" before asking such questions. ;)



    <http://matplotlib.sourceforge.net/api/colors_api.html?highlight=colors#matplotlib.colors>
    matplotlib.colors

    A module for converting numbers or color arguments to RGB or RGBA

    RGB and RGBA are sequences of, respectively, 3 or 4 floats in the range 0-1.

    This module includes functions and classes for color specification
    conversions, and for mapping numbers to colors in a 1-D array of colors
    called a colormap.

    see
    <http://matplotlib.sourceforge.net/examples/pylab_examples/colours.html?highlight=colours>



    >
    >
    >> using color/shading on a tkinter canvas as a visualization for a
    >> two-dimensional grid of numbers? so far my best idea is to use the
    >> same value for R,G and B (fill = '#xyxyxy'), which gives shades of
    >> gray. if possible i'd like to have a larger number of visually
    >> distinct values.

    >
    > The basic idea behind this is that you first normalize the values to a
    > value between zero and one and then use that to look up an according
    > color in an array. Of course you can also do both in one step or compute
    > the colors in the array on the fly (like you did), but it helps keeping
    > things simple at least for a start, and it also allows testing different
    > approaches separately.
    >
    > If the different number of resulting colors isn't good enough then, it
    > could be that the array is too small (its size determines the maximum
    > number of different colours), that the normalization only uses a small
    > range between zero and one (reducing the effectively used number of
    > colours) or simply that your screen doesn't support that many different
    > colors.
    >
    >
    > > i've seen visualizations that seem to use some kind
    > > of hot-versus-cold color coding. does anybody know how to do this?

    >
    > The colour-coding is just the way that above mentioned array is filled.
    > For the hot/cold coding, you could define a dark blue for low values and
    > a bright red for high values and then simply interpolate the RGB triple
    > for values in between.
    >
    > Uli
     
    DJC, Aug 21, 2012
    #3
  4. On Tue, 21 Aug 2012 01:38:33 -0700 (PDT),
    declaimed the following in gmane.comp.python.general:

    > what is the best way of using color/shading on a tkinter canvas as a visualization for a two-dimensional grid of numbers? so far my best idea is to use the same value for R,G and B (fill = '#xyxyxy'), which gives shades of gray. if possible i'd like to have a larger number of visually distinct values. i've seen visualizations that seem to use some kind of hot-versus-cold color coding. does anybody know how to do this? thanks if you can help.
    >


    Last time I worked on something using a "temperature scale" it was
    system with 8-10 bit planes using a color look-up table running from
    dark blue through reds, greens, and finally white. Data values would be
    mapped into the range of colors (32-64 depending on hardware; the other
    bit planes were needed for annotations and windowing support, rather
    than the color-coded data)

    On more modern 24-bit (or higher) systems, where each pixel is
    directly specified... I suppose one could map the data value to the
    H-component of HLS or HSV (0.0-1.0, or 0 to 360deg); then convert back
    to RGB. I'd suggest using a range from 0 to 300deg to avoid confusion as
    the higher "temps" start to shade back to the lowest.

    Strangely, while data plots tend to use dark blue for "cold" and red
    for "hot", the color temperature of light is just the other -- dark red
    is cold, and blue shading into white is hot.

    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Aug 21, 2012
    #4
  5. Am 21.08.2012 19:07, schrieb DJC:
    > On 21/08/12 12:55, Ulrich Eckhardt wrote:
    >> Am 21.08.2012 10:38, schrieb :
    >>> what is the best way

    >>
    >> Define "best" before asking such questions. ;)

    >
    > <http://matplotlib.sourceforge.net/api/colors_api.html?highlight=colors#matplotlib.colors>


    Sorry, that one must have been unclear. The point was that when asking
    for a _best_ solution to a problem, the criteria for evaluating a
    solution must be known. If you don't define them and they are not
    implicit, there is no possible answer to the question.

    Uli
     
    Ulrich Eckhardt, Aug 22, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Maz
    Replies:
    14
    Views:
    858
    Mikhail Arkhipov (Microsoft)
    Oct 19, 2004
  2. Franck

    Color-coding verbs only

    Franck, Feb 13, 2004, in forum: XML
    Replies:
    2
    Views:
    430
    Franck
    Feb 14, 2004
  3. calmar
    Replies:
    11
    Views:
    901
    calmar
    Feb 21, 2006
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    429
    Kamaljeet Saini
    Feb 13, 2009
  5. don

    color coding of text

    don, May 31, 2013, in forum: Java
    Replies:
    38
    Views:
    619
    Rajiv Gupta
    Jun 3, 2013
Loading...

Share This Page