I'm having a problem with the fill() command using semilog or loglog scaling, let me show you with an example, the 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 this nice figure, with the FaceAlpha feature working
The same code but changing plot with semilogx in both commands produces
with the FaceAlpha feature not working.
Is there a way to make it work?
It appears that there is no easy way to create a plot with log scales and transparent objects.
This is because the only renderer that supports transparency OpenGL
does not support logarithmic-scale axes.
The other renderers (ZBuffer, Painters) do support log scale, but don't support transparency. see more here (look under OpenGL vs. Other MATLAB Renderers).
A way that you can try an do it is to plot the log of the data and modify the tick labels etc. For example
% your code bit that 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) % to comapre with 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 for second part!
% the modification I was talking about
figure(2);
%# trick #1
RjbsL=log(Rjbs); % I'm just 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);