# Change decimal separator when plotting with PyPlot (or PythonPlot)

**URL:** https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367
**Category:** General Usage
**Tags:** question, pyplot, locale
**Created:** [January 22, 2023, 5:15pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367 "2023-01-22T17:15:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![marllos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marllos/32/205917_2.png) [@marllos](https://discourse.julialang.org/u/marllos)
#### Post date: [January 22, 2023, 5:15pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/1 "2023-01-22T17:15:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [January 22, 2023, 6:16pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/2 "2023-01-22T18:16:58Z")

</div>

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):

> <https://stackoverflow.com/questions/35929775/how-to-change-point-to-comma-in-matplotlib-graphics>

```julia
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:

```julia
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:

```julia
LC_NUMERIC="is_IS.UTF-8" julia

```

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](https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.ticklabel_format.html)

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:

> **[Decimal separator | Other numeral systems](https://en.wikipedia.org/wiki/Decimal_separator#Other_numeral_systems)**
>
> Unicode defines a decimal separator key symbol (⎖ in hex U+2396, decimal 9110) which looks similar to the apostrophe. This symbol is from ISO/IEC 9995 and is intended for use on a keyboard to indicate a key that performs decimal separation.
> In the Arab world, where Eastern Arabic numerals are used for writing numbers, a different character is used to separate the integer and fractional parts of numbers. It is referred to as an Arabic decimal separator (U+066B, rendered: .mw-parser-output .script...

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [January 22, 2023, 7:25pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/3 "2023-01-22T19:25:25Z")

</div>

Following @Palli’s advice on Windows 11, produces:

```julia
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))

```

![PythonPlot_commas_dots_locale](https://global.discourse-cdn.com/julialang/original/3X/0/6/066f12fa25e98135279f3510cc7808e354fef53b.png)

Linking also this [related thread](https://discourse.julialang.org/t/decimal-commas-instead-of-points/67446).

---

<div class="post-metadata">

### Author: ![marllos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marllos/32/205917_2.png) [@marllos](https://discourse.julialang.org/u/marllos)
#### Post date: [January 22, 2023, 9:09pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/4 "2023-01-22T21:09:50Z")

</div>

Are PyPlot features available in PythonPlot, PythonCall?

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [January 22, 2023, 9:13pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/5 "2023-01-22T21:13:22Z")

</div>

This was demonstrated in PythonPlot and PyCall in the [comment above](https://discourse.julialang.org/t/the-headache-of-the-comma/93367/3), so the answer is yes.

---

<div class="post-metadata">

### Author: ![marllos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marllos/32/205917_2.png) [@marllos](https://discourse.julialang.org/u/marllos)
#### Post date: [January 22, 2023, 9:23pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/6 "2023-01-22T21:23:06Z")

</div>

I called some PyPlot functions and they worked, just wanted to be sure. Thank you mkitti.

---

<div class="post-metadata">

### Author: ![marllos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marllos/32/205917_2.png) [@marllos](https://discourse.julialang.org/u/marllos)
#### Post date: [January 22, 2023, 9:29pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/7 "2023-01-22T21:29:47Z")

</div>

Thank you Palli, thank you Rafael.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [January 23, 2023, 8:49am UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/8 "2023-01-23T08:49:35Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![marllos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marllos/32/205917_2.png) [@marllos](https://discourse.julialang.org/u/marllos)
#### Post date: [January 23, 2023, 2:57pm UTC](https://discourse.julialang.org/t/change-decimal-separator-when-plotting-with-pyplot-or-pythonplot/93367/9 "2023-01-23T14:57:01Z")

</div>

Very good change, I don’t mind, thanks nilshg.
