plot - Matlab's fill doesn't work in semilog or log scales -


i'm having problem fill() command using semilog or loglog scaling, let me show example, code:

rjbs=0.1:0.1:10; pgavsr360=[sin(rjbs)-1; sin(rjbs) ; sin(rjbs)+1]'; pgavsr760=[sin(rjbs)-1.5; sin(rjbs)-0.5 ; sin(rjbs)+0.5]'; figure plot(rjbs,pgavsr360(:,2),'color', 'b', 'linewidth', 2) hold on plot(rjbs,pgavsr760(:,2),'color', [0 0.6 0], 'linewidth', 2) x=[rjbs,fliplr(rjbs)]; y=[pgavsr360(:,1)',fliplr(pgavsr360(:,3)')]; fill(x,y,[0.5 0.5 1], 'facealpha', 0.4) y=[pgavsr760(:,1)',fliplr(pgavsr760(:,3)')]; fill(x,y,[0.3 1 0.3], 'facealpha', 0.4) 

produces nice figure, facealpha feature working nice

the same code changing plot semilogx in both commands produces fail

with facealpha feature not working.

is there way make work?

it appears there no easy way create plot log scales , transparent objects. because renderer supports transparency opengl not support logarithmic-scale axes. other renderers (zbuffer, painters) support log scale, don't support transparency. see more here (look under opengl vs. other matlab renderers).

a way can try plot log of data , modify tick labels etc. example

% code bit doesn't show transparency rjbs=0.1:0.1:10; pgavsr360=[sin(rjbs)-1; sin(rjbs) ; sin(rjbs)+1]'; pgavsr760=[sin(rjbs)-1.5; sin(rjbs)-0.5 ; sin(rjbs)+0.5]'; figure(1) % comapre fig 2 semilogx(rjbs,pgavsr360(:,2),'color', 'b', 'linewidth', 2) hold on semilogx(rjbs,pgavsr760(:,2),'color', [0 0.6 0], 'linewidth', 2) x=[rjbs,fliplr(rjbs)]; y=[pgavsr360(:,1)',fliplr(pgavsr360(:,3)')]; fill(x,y,[0.5 0.5 1], 'facealpha', 0.4) y=[pgavsr760(:,1)',fliplr(pgavsr760(:,3)')]; fill(x,y,[0.3 1 0.3], 'facealpha', 0.4)  ax=get(gca); % important second part!  % modification talking  figure(2);  %# trick #1 rjbsl=log(rjbs); % i'm lazy here  x=[rjbsl,fliplr(rjbsl)]; y=[pgavsr360(:,1)',fliplr(pgavsr360(:,3)')]; fill(x,y,[0.5 0.5 1], 'facealpha', 0.4); hold on y=[pgavsr760(:,1)',fliplr(pgavsr760(:,3)')]; fill(x,y,[0.3 1 0.3], 'facealpha', 0.4) plot(rjbsl,pgavsr360(:,2),'color', 'b', 'linewidth', 2) plot(rjbsl,pgavsr760(:,2),'color', [0 0.6 0], 'linewidth', 2);hold on  %# trick #2 xlim(log(ax.xlim)); set(gca,'xtick',log(ax.xtick),'xticklabel',ax.xticklabel); 

enter image description here


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -