Changing uiaxes title color with button press

조회 수: 7 (최근 30일)
Bradley
Bradley 2024년 3월 31일
댓글: Voss 2024년 3월 31일
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에서 Title에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by