Hello everybody. When the time comes to publish the thesis, we may be faced with a big surprise: the University Library requires the decimal separator to be a comma, and they don’t want any excuses. So, hundreds of graphs need to be redone with another application, this when you were careful to save the points to redo the graphs. I know it’s not Julia’s fault, but this is a headache for users in many countries. Is there a practical way around this problem? I only use PyPlot.
PyPlot is based on matplotlib so whatever works there should work for Julia. I only confirmed I could get the commas in Python.
You likely only need to recreate that line in Julia (or use it as is and call first through PyCall or PythonCall if you use PythonCall.jl PyPlots’s replacement):
plt.rcParams['axes.formatter.use_locale'] = True
For me I didn’t have that locale installed, only my Icelandic is_IS.UTF-8 is installed, which I could replace with in that line:
locale.setlocale(locale.LC_NUMERIC, "de_DE") # Note, that likely may not work, nor my replacement, depending on what you have installed or run: LC_NUMERIC="is_IS.UTF-8" python3
You most likely can run:
and just run your Julia code if you enable the other line. Which seems better, to have under user’s control, not the programmer’s control (still the programmer needs the other line to respect the user’s control…). Note also, the locale may influence other part of your software, e.g. for reading input files.
I don’t know if this works in e.g. Windows, it works at least in Linux, and installing a locale is simple, though outside of the scope of the answer.
This one could also apply: matplotlib.pyplot.ticklabel_format — Matplotlib 3.1.0 documentation
There are many standards, and I couldn’t find a way to explicitly ask for a comma or some other, just implicitly by referring to a country’s locale:
Following @Palli’s advice on Windows 11, produces:
using PythonPlot, PythonCall pyplot.rcParams["axes.formatter.use_locale"] = "True" loc = pyimport("locale") loc.setlocale(loc.LC_NUMERIC, "de_DE") x = -1000:100:20000 plot(x, atanh.(x/20e3))
Linking also this related thread.
Are PyPlot features available in PythonPlot, PythonCall?
This was demonstrated in PythonPlot and PyCall in the comment above, so the answer is yes.
I called some PyPlot functions and they worked, just wanted to be sure. Thank you mkitti.
Thank you Palli, thank you Rafael.
I hope you don’t mind me changing the title of your post - I think your question is potentially relevant for quite a few users in locations where different decimal separators are used, so I changed it to something that hopefully makes it easier for future visitors to find this thread.
Very good change, I don’t mind, thanks nilshg.