Changing uiaxes title color with button press
7 次查看(过去 30 天)
显示 更早的评论
I added a "dark mode" button to my code. Im sure there is a way do this a bit better than I have but I a function with two radial buttons, a light mode and dark mode. When dark mode is clicked the color for everything in the uifigure flips color, typically from white to black or vis versa. I have other buttons that graph stuff, I have a uiaxes figure with a title and for some reason I havent foun a way to change the color. I want to do this in an if loop, below is how I am doing it with the x and y axes. I looked through the uiaxes options extensivly an couldnt find a way to change the color of just the title. Heres how I am doing it for the axes:
if rb1_option == 1
ax.XColor = [0 0 0];
ax.YColor = [0 0 0];
end
if rb2_option == 1
ax.XColor = [1 1 1];
ax.YColor = [1 1 1];
end
This works well for the axes. Any one know of a way to change the title color? Thanks!
0 个评论
采纳的回答
Voss
2024-3-31
ax.Title.Color = [0 0 1]; % or whatever color you like
2 个评论
Voss
2024-3-31
You're welcome!
The important thing to realize is that ax.Title refers to the text object that is the title. So you can set any property of the title by using the syntax "ax.Title.<property> = <value>", e.g.:
ax.Title.Visible = 'off';
ax.Title.EdgeColor = 'b';
ax.Title.LineStyle = '--';
ax.Title.VerticalAlignment = 'top';
ax.Title.Interpreter = 'latex';
% etc.
Here's a list of all text object properties:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!