如何实现条形图重叠的效果。

3 ビュー (過去 30 日間)
hegdeg
hegdeg 2023 年 5 月 16 日
回答済み: teipelto 2023 年 5 月 16 日
代码如下,我想实现B图这样的重叠效果而不是A图的覆盖
close all; %关闭所有图形
clear all; %清除所有变量
clc;
%% 事件请求
A = 0 + (90-0).*rand(1,10)
B = ceil(1 + (6-1).*rand(1,10))
axis([0 100 0 7])
set(gca,'XTick',[0:10:100])
set(gca,'YTick',[0:2:8])
for i=1:1:10
hold on
a= bar(A(i)+5,B(i),10,'linewidth',1.5)
a.FaceColor=[1,1,1]
a.EdgeColor=[0 0 1]
% set(gca,'XTick',1:100:1000)
ylabel('优先级')
xlabel('时间(ms)')
end

採用された回答

teipelto
teipelto 2023 年 5 月 16 日
条形图的填充色应该选“无”,而不是白色
close all; %关闭所有图形
clear all; %清除所有变量
clc;
%% 事件请求
A = 0 + (90-0).*rand(1,10)
B = ceil(1 + (6-1).*rand(1,10))
axis([0 100 0 7])
set(gca,'XTick',[0:10:100])
set(gca,'YTick',[0:2:8])
for i=1:1:10
    hold on
    a= bar(A(i)+5,B(i),10,'linewidth',1.5,'FaceColor','none','EdgeColor','black');
end
    ylabel('优先级')
    xlabel('时间(ms)')

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange数学 についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!