Clear Filters
Clear Filters

Changing uiaxes title color with button press

7 views (last 30 days)
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!

Accepted Answer

Voss
Voss on 31 Mar 2024
ax.Title.Color = [0 0 1]; % or whatever color you like
  2 Comments
Bradley
Bradley on 31 Mar 2024
Duh. Thanks for this. I tried a lot of options and thought I tried that already, it works obviously. thanks again.
Voss
Voss on 31 Mar 2024
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:

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!