Matlab文本框alpha不会调整所有背景色 [英] Matlab textbox alpha does not adjust all background color

查看:213
本文介绍了Matlab文本框alpha不会调整所有背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的脚本,可以绘制一些随机的东西,并放置一个带有背景色的textbox.我正在尝试更改背景的透明度,以使该图显示出来.

I have a very simple script that plots some random stuff and puts a textbox with background color. I am attempting to change the transparency of the background so that the plot shows through.

我有以下代码:

x = rand(10);
plot(sin(x))
a = annotation('textbox', [0.5 0.5 0.1 0.1], 'String', 'Some Random Text');
set(a, 'BackgroundColor', [.7 .9 .7]);
set(a, 'FaceAlpha', 0.5);

结果是这样的图像:

因此,显然透明起作用了,因为部分背景颜色是透明的.

So obviously the transparency has worked because part of the background colour is transparent.

为什么所有这些都不透明?我在这里做错了吗?

推荐答案

更新:Mathworks确认这可能是一个错误,该错误可能会在2014b(将于2014年7月发布)中修复.临时解决方法是:

Update: Mathworks confirmed that it probably is a bug which might be fixed in 2014b (to be released in July 2014). A temporary workaround is:

plot(sin(rand(10)))
a = annotation('textbox', [0.5 0.5 0.1 0.1], 'String', 'Some Random Text');
b = annotation('textbox', get(a,'Position'));
set(b, 'BackgroundColor', [0 0.5 0]);
set(b, 'FaceAlpha', 1);
uistack(a,'top')

为文本添加一个注释,为背景颜色添加另一个注释.

One annotation for the text and below another for the background color.

实际上这可能是Matlab的错误.有关注释的文档说:

It might be a Matlab bug actually. The documentation about annotations says:

FaceAlpha

FaceAlpha

范围[0 1]对象背景的透明度的标量alpha值. 定义对象背景色的程度 透明的.值1(默认值)会使背景不透明, 值0使背景完全透明(即, 无形的).默认值为1.

Scalar alpha value in range [0 1] Transparency of object background. Defines the degree to which the object's background color is transparent. A value of 1 (the default) makes the background opaque, a value of 0 makes the background completely transparent (that is, invisible). The default value is 1.

我得出的结论是整个背景都应该受到影响,但是我可以证实,事实并非如此(Matlab 2012b).我可能会向他们提交错误报告.

I would conclude that the whole background should be affected but I can confirm that this is not the case also here (Matlab 2012b). I might file a bug report with them.

要临时修复,请将背景色设置得尽可能亮(例如[0.9、0.9、0.9]),这样就不会立即看到效果.

For a temporary fix, set the backgroundcolor as bright as possible ([0.9, 0.9, 0.9] for example) then one doesn't see the effect immediately.

这篇关于Matlab文本框alpha不会调整所有背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆