Change axis colour matlab

1,794 views (last 30 days)
Sarah Yun
Sarah Yun on 19 Jan 2020
Answered: Image Analyst on 19 Jan 2020
Hi,
I want a black figure background and white figure axis.
subplot(2, 2, [1 3]);
hold on
plotc(X, Y);
xlabel('UTM Easting (m)');
ylabel('UTM Northing (m)');
% This sets background color to black
set(gca,'color','k');
hold off
How can I set figure axis to white (against the black figure background)?

Accepted Answer

Image Analyst
Image Analyst on 19 Jan 2020
Try this, where I change several properties. There are lots more things you can tweak individually, just click the "See all properties" link in the command window to see a list of them.
X = 1 : 20;
Y = rand(1, 20);
subplot(2, 2, [1 3]);
hold on
plot(X, Y, 'gs-');
grid on;
xlabel('UTM Easting (m)');
ylabel('UTM Northing (m)');
% Get handle to current axes.
ax = gca
% This sets background color to black
ax.Color = 'k'
ax.YColor = 'r';
darkGreen = [0, 0.6, 0];
ax.XColor = darkGreen;
ax.GridColor = 'y';
ax.GridAlpha = 0.9;
ax.FontSize = 15;
ax.FontWeight = 'bold';
hold off
0000 Screenshot.png

More Answers (1)

Star Strider
Star Strider on 19 Jan 2020
Try this:
x = linspace(20, 50, 29);
y = sin((x-20)/30 * 2 * pi);
figure
plot(x, y)
xt = xticks(gca);
xt2 = compose('%.0f\\circW',xt);
set(gca,'xtickLabel',xt2);
set(gca, 'Color','k', 'XColor','w', 'YColor','w')
set(gcf, 'Color','k')
producing:
1Change axis colour matlab - 2020 01 19.png
Make appropriate changes to get the result you want.
Also see: Axis Properties and Figure Properties for more options.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!