David
David

Reputation: 91

colormap/datatip issue in Matlab figure

I run this code

A = uint8( ones( 200 ) );
a = [ A * 0 A * 1; ...
      A * 2 A * 3 ];

color_map = [ 0    0    0; ...
              0.3  0.3  0.3; ...
              0.9  0.3  0.1; ...
              1    1    1; ...
              zeros( 252, 3 ) ];

h = image( a );
colormap( color_map );

Then, I select a point in the figure using the datatip feature. This makes the colors in the figure change. They still have the same indices and RBG values, but they are different colors. Then, I delete the datatip, and the colors return to their proper colors.

Using,

set(gcf, 'Renderer', 'opengl')

makes the issue go away, but I'm wondering if there is a way to avoid having to do that? I am using MATLAB R2013b.

Upvotes: 9

Views: 505

Answers (1)

NoamG
NoamG

Reputation: 165

This line prevents the behaviour you mentioned above:

set(0, 'DefaultFigureRenderer', 'opengl');

It sets the renderer for all the new figures. You can place that line in the startup.m file.

To learn more about startup file, go to:

http://www.mathworks.com/help/matlab/ref/startup.html

(you basicly generate that file if it does not exist, and put there the code you want to run whenever Matlab starts up).

Upvotes: 1

Related Questions