Convert days and months in french for an axis of type DateTimeRuler
조회 수: 6 (최근 30일)
이전 댓글 표시
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일
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일
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!