Changing uiaxes title color with button press

6 次查看(过去 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!

采纳的回答

Voss
Voss 2024-3-31
ax.Title.Color = [0 0 1]; % or whatever color you like
  2 个评论
Bradley
Bradley 2024-3-31
Duh. Thanks for this. I tried a lot of options and thought I tried that already, it works obviously. thanks again.
Voss
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 CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by