MATLAB Answers

Sharah
0

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

Asked by Sharah
on 27 Oct 2016
Latest activity Answered by Image Analyst
on 27 Oct 2016
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 Comments

Please post what code you are using. Axes are white by default, with black text. Do you mean you are making the grid lines white? If so when I do this everything else remains unchanged, so I'm not really sure what settings you are changing.
@adam I mean the axes line

Sign in to comment.

Tags

3 Answers

Answer by Image Analyst
on 27 Oct 2016

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 Comment

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

Sign in to comment.


Answer by Jan
on 27 Oct 2016

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');

  0 Comments

Sign in to comment.


Answer by Image Analyst
on 27 Oct 2016

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.

  0 Comments

Sign in to comment.