change only the background color of contour plot
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a contour plot. I want to change only the background color not the contour color. Can you please suggest me how can I do that?
0 Kommentare
Antworten (1)
Abhishek
am 7 Mär. 2025
Hi,
In order to change the background colour of a contour plot, without affecting the contour colours, you can use the "set" function. The “set” function is used to change the “Color” property of the current axes. This changes the background colour of the plot area without affecting the contour lines.
For more details, you can refer to the below MATLAB documentation on “set” function: https://www.mathworks.com/help/releases/R2024b/matlab/ref/set.html
The following sample code will display a contour plot with a light blue background.
[X, Y] = meshgrid(-5:0.1:5, -5:0.1:5);
Z = sin(sqrt(X.^2 + Y.^2));
contour(X, Y, Z);
% Adjust the RGB values in the set function to
% change the background to any color you prefer.
set(gca, 'Color', [0.8, 0.9, 1.0]);
title('Light Blue Background');
I have attached the plot for both blue as well as green background plots. Hope this solves the issue.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Contour Plots 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!