MATLAB Answers

how to change the axis line color white but maintain the font color black?

275 ビュー (過去 30 日間)
Sharah
Sharah 2016 年 10 月 27 日
編集済み: Image Analyst 2020 年 7 月 24 日
I am trying to get a graph look like this, but when I change the color of axis to white the font becomes white too
  2 件のコメント
Sharah
Sharah 2016 年 10 月 27 日
@adam I mean the axes line

サインインしてコメントする。

回答 (3 件)

Image Analyst
Image Analyst 2016 年 10 月 27 日
Does this help:
y = sin([1:40]/10);
plot(y, 'm*-');
grid on;
ax = gca % Get handle to current axes.
ax.XColor = 'r'; % Red
ax.YColor = 'b'; % Blue
ax.GridAlpha = 0.9; % Make grid lines less transparent.
ax.GridColor = [0.1, 0.7, 0.2]; % Dark Green.

Jan
Jan 2016 年 10 月 27 日
Create 2 axes: 1 for the lables and another on top for the grid:
Axes1H = axes('NextPlot', 'add');
Axes1H = axes('NextPlot', 'add', 'YTickLabel', {}, 'XTickLabel', {}, ...
'XColor', [1,1,1], 'YColor', [1,1,1], ...
'Color', [0.5, 0.5, 0.5], ...
'Box', 'on', 'XGrid', 'on', 'YGrid', 'on');
  2 件のコメント
Image Analyst
Image Analyst 2020 年 7 月 24 日
As I said in my Answer, leave off the semicolon when you call Axes1H. Then you'll get a partial list of properties you can change. Click the Show All Properties link to see a list of all of them. There are lots of things there you can change including the colors and sizes of axes and tick marks.

サインインしてコメントする。


Image Analyst
Image Analyst 2016 年 10 月 27 日
Do this right after you plot something.
ax = gca % Don't use a semicolon.
Then, in the command window, click the link to show all properties. There you can see how you can change virtually anything.
  1 件のコメント
Sharah
Sharah 2016 年 10 月 27 日
I know that one, but the problem is when I change fore example the 'XColor' which is the axis color on X side to white, the font of XTickLabel will change to white too. How to maintain the black font color but only change the axis color

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by