Convert days and months in french for an axis of type DateTimeRuler
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Laurent Fritz
el 23 de Nov. de 2024
Comentada: Shivam Gothi
el 24 de Nov. de 2024
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 comentarios
Respuesta aceptada
Shivam Gothi
el 23 de Nov. de 2024
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 comentarios
Shivam Gothi
el 24 de Nov. de 2024
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!