semilog x in boundedline doesn't work
4 次查看(过去 30 天)
显示 更早的评论
I tried multiple solutions offered, but once I make the x-axis logarithmic, the shading disappears.
for e.g. in this example
%% Example 1: Plotting lines using various syntax options
%
% This example builds the 4-panel example image used on the MatlabCentral
% File Exchange, which shows several different methods for supplying line
% coordinates, bounds coordinates, and shading options.
%
% The first axis plots two lines using the LineSpec option for input, which
% allows yoy to set line color, line color, and marker type for each line.
% The bounds on the first line vary over x, while the bounds on the second
% line are constant for all x. An outline is added to the bounds so the
% overlapping region can be seen more clearly.
x = linspace(0, 2*pi, 50);
y1 = sin(x);
y2 = cos(x);
e1 = rand(size(y1))*.5+.5;
e2 = [.25 .5];
ax(1) = subplot(2,2,1);
[l,p] = boundedline(x, y1, e1, '-b*', x, y2, e2, '--ro');
outlinebounds(l,p);
title('Opaque bounds, with outline');
axis tight;
The code works fine but if I add the line -
set(gca,'xscale','log')
in the end to make semilog x plot, the shading disappears. Any help is appreciated. Thanks!
0 个评论
采纳的回答
Voss
2023-10-1
编辑:Voss
2023-10-1
The problem is the 0 in your x vector. Non-positive numbers cannot be represented on log scale. (Specifically, log(0) is negative infinity, which causes a problem drawing a patch with an infinite x-coordinate.) Change the zero to something small but positive.
x = linspace(1e-2, 2*pi, 50);
y1 = sin(x);
y2 = cos(x);
e1 = rand(size(y1))*.5+.5;
e2 = [.25 .5];
ax(1) = subplot(2,2,1);
[l,p] = boundedline(x, y1, e1, '-b*', x, y2, e2, '--ro');
outlinebounds(l,p);
title('Opaque bounds, with outline');
axis tight;
set(gca,'xscale','log')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Volume Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!