在 matlab 中更改线条透明度
Change line transparency in matlab
我是 matlab 的新手,正在尝试绘制一些回归线,但要使它们透明。我在这里读到:https://uk.mathworks.com/matlabcentral/answers/44442-change-opacity-of-lines 应该可以通过将 alpha 指定为颜色的最终值来做到这一点,但是,这对我来说没有任何改变。有什么想法可以使我的线条透明吗?我是运行版本R2021a。
plot(MC_age(:,i),f(i,:),'LineWidth',0.1,"Color", [0.4, 0.4, 0.4, 0.8])
谢谢
抱歉,我没有 2021a,但我已经在 R2020b 和 R2017a 上测试了以下代码
x = 1:10;
y1 = rand(size(x));
y2 = rand(size(x));
y3 = rand(size(x));
figure;hold all;
plot(x,y1,'LineWidth',10,"Color", [0.4, 0.4, 0.4, 1])
plot(x,y2,'LineWidth',10,"Color", [0.4, 0.4, 0.4, 0.5])
plot(x,y3,'LineWidth',10,"Color", [0.4, 0.4, 0.4, 0.2])
它可以如你所愿,但不幸的是 it seems that others have experienced a problem doing the same thing with 2021a.
有一个名为 patchline()
的 this function,它实际上是将您的绘图绘制为补丁对象。下载它,然后使用以下代码(在保存 patchline 的同一目录中)
x = 1:10;
y1 = rand(size(x));
y2 = rand(size(x));
y3 = rand(size(x));
figure;hold all;
p1 = patchline(x,y1,'edgecolor',[0.4 0.4 0.4],'linewidth',2,'edgealpha',1);
p2 = patchline(x,y2,'edgecolor',[0.4 0.4 0.4],'linewidth',2,'edgealpha',0.5);
p3 = patchline(x,y3,'edgecolor',[0.4 0.4 0.4],'linewidth',2,'edgealpha',0.2);
给我下面的图片
我还在 2017a 和 2020b 测试了这个...这对你 2021a 有用吗?
我是 matlab 的新手,正在尝试绘制一些回归线,但要使它们透明。我在这里读到:https://uk.mathworks.com/matlabcentral/answers/44442-change-opacity-of-lines 应该可以通过将 alpha 指定为颜色的最终值来做到这一点,但是,这对我来说没有任何改变。有什么想法可以使我的线条透明吗?我是运行版本R2021a。
plot(MC_age(:,i),f(i,:),'LineWidth',0.1,"Color", [0.4, 0.4, 0.4, 0.8])
谢谢
抱歉,我没有 2021a,但我已经在 R2020b 和 R2017a 上测试了以下代码
x = 1:10;
y1 = rand(size(x));
y2 = rand(size(x));
y3 = rand(size(x));
figure;hold all;
plot(x,y1,'LineWidth',10,"Color", [0.4, 0.4, 0.4, 1])
plot(x,y2,'LineWidth',10,"Color", [0.4, 0.4, 0.4, 0.5])
plot(x,y3,'LineWidth',10,"Color", [0.4, 0.4, 0.4, 0.2])
它可以如你所愿,但不幸的是 it seems that others have experienced a problem doing the same thing with 2021a.
有一个名为 patchline()
的 this function,它实际上是将您的绘图绘制为补丁对象。下载它,然后使用以下代码(在保存 patchline 的同一目录中)
x = 1:10;
y1 = rand(size(x));
y2 = rand(size(x));
y3 = rand(size(x));
figure;hold all;
p1 = patchline(x,y1,'edgecolor',[0.4 0.4 0.4],'linewidth',2,'edgealpha',1);
p2 = patchline(x,y2,'edgecolor',[0.4 0.4 0.4],'linewidth',2,'edgealpha',0.5);
p3 = patchline(x,y3,'edgecolor',[0.4 0.4 0.4],'linewidth',2,'edgealpha',0.2);
给我下面的图片
我还在 2017a 和 2020b 测试了这个...这对你 2021a 有用吗?