Adding specific colors on a fig file

조회 수: 1 (최근 30일)
Wissem-Eddine KHATLA
Wissem-Eddine KHATLA 2024년 4월 7일
댓글: Wissem-Eddine KHATLA 2024년 4월 7일
Hello everyone,
Is it possible to add, directly in Matlab, some colors on specific zones of a fig file ?
For instance, if I want the area below a curve to be in a specific color and the area above with another one ?
Thank you for your help,
Sincerely.

채택된 답변

Mann Baidi
Mann Baidi 2024년 4월 7일
Hi,
As per the understanding of the question, you would like to add different background color for area above and area below the plotted line.
This can be done using the 'area' function in MATLAB. Here is an example for the same.
% Define constants
a = 0.1; % adjust this value to change the shape of the parabola
% Define range of y values
y = linspace(-10, 10, 100);
% Calculate corresponding x values
x = a * y.^2;
area(x)
You can explore more about the 'area' function by referring to the following link:
I hope this helps.
  댓글 수: 1
Wissem-Eddine KHATLA
Wissem-Eddine KHATLA 2024년 4월 7일
@Mann Baidi Thank you : this is indeed what I was looking for. Will have a look on the documentation ! Thanks again :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by