1

I am plotting values using the "patch" function in Matlab, where data stored in a vector define the color of the patches.

My data range from 0 to 5, but most of the data are bunched around 0.5 and 4.5. If I set the limits of the colormap [0-1] I lose the detail in the higher values and if I set the range [0-5], I lose information for the lower values in my plot.

I am trying to create my own colormap, defining the colours in three RGB columns, but don't understand how the colours are distributed. How do I define the spacing, in order to get more definition in lower and higher values? Is there an other way around?

Maxim L
  • 209
  • 6
  • 15
  • 2
    Many different ways to do it programmatically, but if it's only for one time use, you could use the Matlab built-in [`colormapeditor`](http://uk.mathworks.com/help/matlab/ref/colormapeditor.html) – Hoki Jul 02 '15 at 13:27
  • I'd say you need a [**non-linear colormap**](http://stackoverflow.com/a/20629872/2605073). – Robert Seifert Jul 02 '15 at 14:46
  • This might help you: http://stackoverflow.com/questions/17230837/how-to-create-a-custom-colormap-programatically/17232355#17232355 just set your colours at the `x` points relevant to you i.e. something like `x = [0 0.5 4.5 5]`. This is essentially what I think [Naveh's answer](http://stackoverflow.com/a/31185885/1011724) is suggesting. – Dan Jul 02 '15 at 14:48

1 Answers1

1

From the colormap documentation:

To create a custom colormap, specify map as a three-column matrix of RGB triplets where each row defines one color. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]. For example, this matrix defines a colormap containing five colors.

map = [0.2, 0.1, 0.5
    0.1, 0.5, 0.8
    0.2, 0.7, 0.6
    0.8, 0.7, 0.3
    0.9, 1, 0];

What I would do is take your chosen colormap and interpolate more values in the middle of it, so that most variation is pushed to the lower and upper values.

buzjwa
  • 2,632
  • 2
  • 24
  • 37