Set(...'facealpha'..) gives me a very odd problem

3 views (last 30 days)
Stefan
Stefan on 13 Mar 2014
Commented: Stefan on 14 Mar 2014
Dear all,
Intro: I have worked my entire day on this problem and I cannot seem to be able to solve it. The question also appears on stackoverflow: http://stackoverflow.com/posts/22377469/revisions
Now the problem essentially is that while executing the command:
set([a,b,c,d],'edgecolor','none','facealpha',0.05);
The functionalities such as 'plot' and 'bar' stops working.
Code:
h = figure('Units', 'pixels', ...
'Position', [700 500 1000 500]);
axes('Position',[0.1 0.50 0.85 0.45])
hold
%First fill:
z = [str(1) str(end) str(end) str(1)];
y = [4 4 10 10];
a = fill(z,y,[0 0.8 0.0])
%Second fill:
y2 = [0 0 4 4];
b = fill(z,y2,[0.8 0.0 0.0])
%set(a,'edgecolor','none','facealpha',0.1);
%Third fill
y3 = [0 0 3 3];
c = fill(z,y3,[1 0.0 0.0])
%set(a,'edgecolor','none','facealpha',0.1);
%Fourth fill
y4 = [10 10 20 20];
d = fill(z,y4,[0.8 0.0 0.0])
size(str)
e = plot(str',bg1(1:1:limit),'b.');
f = plot(str(1:5:end),cgm1(1:1:limit/5),'.','color',[0.5 0.5 0.5]);
%set([a,b,c,d],'edgecolor','none','facealpha',0.05);
axis([min(str) max(str) 0 20])
datetick('x', 'HH:MM','keeplimits');
set( gca , 'FontName' , 'Helvetica' );
ylabel('Blood Glucose [mmol/L]');
legend([e,f],'No feedforward','CGM signal','location','NorthEast')
hold off
axes('Position',[0.1 0.1 0.85 0.35])
hold
bar(str(1:5:end),u(1:1:limit/5,1),1);
axis([min(str) max(str) 0 max(u(:,1))])
This result in following picture:
While I want to add transparency I uncomment the line of code:
set([a,b,c,d],'edgecolor','none','facealpha',0.05);
and the result, of the exact same plot, become following:
Now as you might notice, something goes completely wrong. The plot function suddenly gets non-smooth (which is not the case for the data) and the function bar suddenly do not use the correct interval. I have absolutely no idea what is going on. Let me know if you have any suggestions or ideas to what is causing the set function to turn my plot into a complete mess.
Thanks a lot, I appreciate it!
Can you help me? Thanks!

Answers (1)

Kelly Kearney
Kelly Kearney on 13 Mar 2014
When alpha causes weird behavior, my first instinct is to check the renderer. If you run
set(gcf, 'renderer', 'zbuffer')
after the script with the set([a;b;c;d], 'facealpha', ...) uncommented does, everything look okay except for the now-missing transparency?
  8 Comments
Stefan
Stefan on 14 Mar 2014
Tried on another Lenovo machine and also by using the area function instead of the fill function. This still does not work and are extremely frustating. I will go the 50km to go to a friend who has a Mac. Fingers crossed lol.

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!