Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using transparency value over imagesc

Tags:

plot

matlab

When I plot a patch with transparency < 1 over an image created with imagesc (Matlab R2012a), I get something that looks like lots of "tick lables", or numbers over the image along the axes. The following code reproduces the problem:

imagesc(rand(10,20))
hold on
patch([5 5 15 15],[3 7 7 3],'r','facealpha',.5)

Is this a bug, or is there a way to do it properly?

EDIT The numbers disappear if I set set(gca,'xtick',[],'ytick',[]), so it is indeed tick-related. I would of course prefer having ticks on my figure.

imagesc with numbers on it

like image 851
Itamar Katz Avatar asked Nov 04 '22 07:11

Itamar Katz


1 Answers

This kind of graphical artifact is usually related to the renderer. Particularly the OpenGL renderer seems to mess up on certain combinations of Matlab release, graphics card, and operating system.

The standard workaround is to change the renderer from OpenGL to zBuffer in the figure properties, which is achieved via the command

set(gcf,'renderer','zbuffer')

Unfortunately, OpenGL is the only renderer that supports transparency, so this solution won't work for you.

As a possible alternative workaround, you can switch from hardware to software OpenGL renderer via the command

opengl software

Check the help on opengl to find out how to set this up in case you're in a *nix environment.

like image 76
Jonas Avatar answered Nov 15 '22 08:11

Jonas