I want to add some information in the top x axis

조회 수: 3 (최근 30일)
Odd-Simon Simonsen
Odd-Simon Simonsen 2023년 3월 16일
답변: Sanjana 2023년 3월 30일
I have a code that plots the temperature from 4 different sensors, and the x axis shows the logging number, the y axis shows the temperature.
This is my code:
plot(dat00001m.Var3,'DisplayName','dat00001m.Var3');
hold on;
plot(dat00001m.Var4,'DisplayName','dat00001m.Var4');
plot(dat00001m.Var5,'DisplayName','dat00001m.Var5');
plot(dat00001m.Var6,'DisplayName','dat00001m.Var6');
ylabel('Temperatur [℃]');
xlabel('Log#');
legend({'chan101', 'chan102', 'chan103', 'chan104'}, 'Location', 'northeast');
hold off;
output:
But, I want to add another x label on top of the plot that shows the real dime the sensor logged the information. This is saved in my table as 'dat0001m.Var2'.
I want this to log on the same pharameters that are set for the log, so value 0, 500, 1000, 1500, 2000, 2500.
How can i do this? Thank you!

답변 (1개)

Sanjana
Sanjana 2023년 3월 30일
Hi,
I understand that you are looking for ways to label the x-axis using the data in "dat0001m.Var2".
To accomplish this, you can utilize the "xticklabels" function. This function allows you to pass a string array containing the data from "dat0001m.Var2" file as labels for the x-axis.
Please refer to the below link for further help,
Hope this helps!

카테고리

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