change only the background color of contour plot
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Abhishek
2025 年 3 月 7 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!