I would like to report more dates: for example every month or every week
I use plot to draw it..(
plot(Ax_Sys,XDates(locs(:,i)),sig,'DisplayName',STR_name{i},'Color',SumCTR_color(i,:),'LineWidth',1);)

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Jan. 2025
Verschoben: Walter Roberson am 20 Jan. 2025

0 Stimmen

load matlab_Xdates
load matlab_TeStrum
load matlab_fig
Ax_Eq.Parent
ans =
0x0 empty GraphicsPlaceholder array.
Somehow, you have an axes that has no Parent, so gca is creating a new axes, and that new axes defaults to numeric.
You should also be specific about the axes to parent graphics operations to.
legend_lines(1)=plot(Ax_Eq,XDates,TE_strum(:,1));
xtickformat(Ax_Eq, 'MMM u' );% DA SISTEMARE
xticks(Ax_Eq, XDates(1):calmonths(1):XDates(end));% DA SISTEMARE

3 Kommentare

shamal
shamal am 20 Jan. 2025
thank you..because i don't see in the format to specify axis
The last line,
___ = xticks(ax,___)
is indicating that you can pass an axes as the first parameter.
shamal
shamal am 20 Jan. 2025
okk thank

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 17 Jan. 2025

0 Stimmen

Use xticks
If you must report every week, then you will probably want to use xtickangle

9 Kommentare

shamal
shamal am 18 Jan. 2025
Bearbeitet: shamal am 18 Jan. 2025
hi,
K>> XDates(1):calmonths(1):XDates(end)
ans =
1×25 datetime array
Columns 1 through 6
01/01/2023 01/02/2023 01/03/2023 01/04/2023 01/05/2023 01/06/2023
Columns 7 through 12
01/07/2023 01/08/2023 01/09/2023 01/10/2023 01/11/2023 01/12/2023
Columns 13 through 18
01/01/2024 01/02/2024 01/03/2024 01/04/2024 01/05/2024 01/06/2024
Columns 19 through 24
01/07/2024 01/08/2024 01/09/2024 01/10/2024 01/11/2024 01/12/2024
Column 25
01/01/2025
%%****************MY CODE************************
legend_lines(i)=plot(Ax_Eq,XDates,TE_strum(:,i)','DisplayName',STR_name{i},'Color',col(i,:),'LineWidth',width_arr(i));
text(Ax_Eq,r-2,TE_strum(end,i),strcat({' '},num2str(i)),'Color',col(i,:),'Interpreter','none');
xticks(XDates(1):calmonths(1):XDates(end));
Error using xticks (line 33)
Tick values must be a vector of increasing numeric values.
Walter Roberson
Walter Roberson am 18 Jan. 2025
Bearbeitet: Walter Roberson am 18 Jan. 2025
Are you still using R2023a ? You have the habit of not filling in the Product and Release fields when creating Questions, but those are important information.
What shows up for
legendLines(i).Parent.XAxis
?
shamal
shamal am 18 Jan. 2025
i use '24.1.0.2603908 (R2024a) Update 3'
Cris LaPierre
Cris LaPierre am 18 Jan. 2025
Maybe alos share XDates.Format
What shows up for
which -all xticks
shamal
shamal am 18 Jan. 2025
K>> XDates.Format
ans =
'dd/MM/yyyy'
shamal
shamal am 18 Jan. 2025
K>> which -all xticks
C:\Program Files\MATLAB\R2024a\toolbox\matlab\graph3d\xticks.m
Cris LaPierre
Cris LaPierre am 20 Jan. 2025
Bearbeitet: Cris LaPierre am 20 Jan. 2025
I can't duplicate your error, and I show an example that works with the expected data.
Please share all the data used to create your figure. Consider saving your variables to a mat file and attaching it to your post using the paperclip icon. Since you are specifiying a target axis, it would be insightful to see all relevant code.
shamal
shamal am 20 Jan. 2025
Bearbeitet: shamal am 20 Jan. 2025
Ok i try to send it
legend_lines(1)=plot(Ax_Eq,XDates,TE_strum(:,1));
xtickformat( 'MMM u' );% DA SISTEMARE
xticks(XDates(1):calmonths(1):XDates(end));% DA SISTEMARE
Error using xtickformat (line 34)
Invalid numeric tick label format.
Error in untitled2 (line 7)
xtickformat( 'MMM u' );

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Axes Appearance finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2024a

Gefragt:

am 17 Jan. 2025

Kommentiert:

am 20 Jan. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by