Change axis colour matlab

1.718 Ansichten (letzte 30 Tage)
Sarah Yun
Sarah Yun am 19 Jan. 2020
Beantwortet: Image Analyst am 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)?

Akzeptierte Antwort

Image Analyst
Image Analyst am 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

Weitere Antworten (1)

Star Strider
Star Strider am 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.

Kategorien

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by