Change axis colour matlab

조회 수: 1,600 (최근 30일)
Sarah Yun
Sarah Yun 2020년 1월 19일
답변: Image Analyst 2020년 1월 19일
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)?

채택된 답변

Image Analyst
Image Analyst 2020년 1월 19일
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

추가 답변 (1개)

Star Strider
Star Strider 2020년 1월 19일
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.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by