Convert days and months in french for an axis of type DateTimeRuler
34 ビュー (過去 30 日間)
古いコメントを表示
Laurent Fritz
2024 年 11 月 23 日 15:39
コメント済み: Shivam Gothi
2024 年 11 月 24 日 9:25
Hello,
I try to change language/locale for labels of axis of type DateTimeRuler with set(0,'Language',"fr_FR") without success ! Is ther another solution ?
0 件のコメント
採用された回答
Shivam Gothi
2024 年 11 月 23 日 17:39
As per my understanding, you are trying to show the labels of axis containing "datetime" data in "French" language. There is no direct way to achieve the objective, but I found few workarounds which may help to resolve your question.
1) You can change the output dates to any user-preferred Locale
use Locale option from preferences (Preferences -> Command Window -> Datetime format -> Locale). If you can not see a particular Locale in a drop down menu, just type in there and apply the changes. It will accept it if you type in correctly. For example, if you want the output to be displayed in French, type the Locale as "fr_FR" and apply the changes. You will observe the output from "datetime" function displayed in German
2) You can use "cellstr" function to specify the "locale" property as demonstrated below:
%C = cellstr(D,'fmt',"fr_FR") %fmt = output format of datetime object (D)
Refer to the documentation to find more information about the function:
I have also illustrated its use by a small example as shown below:
%create an array of datetime object for demonstration purpose
year=2024+ones(1,6);
month= [1 2 3 4 5 6];
day=13+ones (1,6);
datearr =datetime(year, month, day)
C=cellstr(datearr,'MMM d, yyyy',"fr_FR") %you can specify any datetime format "fmt". Here, it is 'MMM d, yyyy'
%create data for y-axis (for demonstration)
y_data=[1 2 3 4 5 6];
A=plot(datearr,y_data);
A.Parent.XTickLabel=C;
As seen, the xlabels are now appearing in French language. I hope this answers your question !
2 件のコメント
Shivam Gothi
2024 年 11 月 24 日 9:25
Thankyou for the reply. You can find the "preferences" tab as shown in the below figure.
Set the "Locale" property to "fr-FR" by manually typing it and then clicking "apply". It will only change the Locale of "datetime" object. Not the entire Command window.
I tried this and found to be working.
Moreover, if you find any of the responses helpful and they resolve the issue you're facing, it would be wonderful if you could mark the answer as "accepted". This will assist the community users in finding more precise and accurate solutions.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!