set legend to non transparent
118 ビュー (過去 30 日間)
古いコメントを表示
How is it possible to set a legends transparency to zero? i.e. completely opaque
Regards
1 件のコメント
Matt J
2016 年 11 月 10 日
I wonder if this was in reference to plots generated with plotyy? I have recently generated a case where the legend box is opaque with respect to the left hand plots and transparent with respect to the right hand plots. No idea how to adjust this. The axis Color properties don't make any difference...
回答 (3 件)
Cedric
2015 年 8 月 16 日
編集済み: Cedric
2015 年 8 月 16 日
What do you mean by opaque? By default the legend is boxed and opaque:
>> t = 0 : 0.1 : 10 ; plot( t, sin(t), 'b', t, cos(t), 'r' ) ; grid on ;
>> lh = legend( {'sin', 'cos'} ) ;
where lh stands for legend handle.
Then you can modify properties:
>> set( lh )
Box: {'on' 'off'}
BusyAction: {'queue' 'cancel'}
ButtonDownFcn: {}
Children: {}
Color: {1x0 cell}
CreateFcn: {}
DeleteFcn: {}
EdgeColor: {1x0 cell}
FontAngle: {'normal' 'italic'}
FontName: {}
FontSize: {}
FontWeight: {'normal' 'bold'}
HandleVisibility: {'on' 'callback' 'off'}
HitTest: {'on' 'off'}
Interpreter: {'none' 'tex' 'latex'}
Interruptible: {'on' 'off'}
LineWidth: {}
Location: {1x19 cell}
Orientation: {'horizontal' 'vertical'}
Parent: {}
PickableParts: {'visible' 'none' 'all'}
Position: {}
Selected: {'on' 'off'}
SelectionHighlight: {'on' 'off'}
String: {}
Tag: {}
TextColor: {1x0 cell}
UIContextMenu: {}
Units: {'inches' 'centimeters' 'characters' 'normalized' 'points' 'pixels'}
UserData: {}
Visible: {'on' 'off'}
e.g. to remove the box, or to remove the box edges. Without the box the background is transparent:
>> set( lh, 'Box', 'off' ) ;
If you want an opaque background, e.g. grey, without edge, keep it boxed and change the edge color to match the (background) color :
>> set( lh, 'Box', 'on', 'Color', [0.8,0.8,0.8], 'EdgeColor', get( lh, 'Color' )) ;
0 件のコメント
Walter Roberson
2015 年 8 月 16 日
When I read the documentation in R2014a (older graphics style) and R2015a (newer graphics style) I see no evidence that there is any transparency associated with legends. When I test with R2014a, none of the generated objects has any capacity for transparency, including the hidden objects.
0 件のコメント
Afiq Azaibi
2024 年 4 月 26 日
Starting in R2024a, legend supports the ability to control the level of transparency with the BackgroundAlpha property. Below is a short example:
plot(magic(7));
grid on;
set(gca, 'Color', [.88 .88 .88]);
l = legend(BackgroundAlpha=.7);
Setting the value to 0 will make it fully transparent and a value 1 of will make it fully opaque which is the default behavior.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!