# Can't seem to change PyPlot latex font

**URL:** <https://discourse.julialang.org/t/cant-seem-to-change-pyplot-latex-font/39886>\
**Category:** Visualization\
**Tags:** pyplot\
**Created:** [May 21, 2020, 3:21pm UTC](https://discourse.julialang.org/t/cant-seem-to-change-pyplot-latex-font/39886 "2020-05-21T15:21:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KK\_JuliaNoob](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@KK\_JuliaNoob](https://discourse.julialang.org/u/KK_JuliaNoob)\
**Post date:** [May 21, 2020, 3:21pm UTC](https://discourse.julialang.org/t/cant-seem-to-change-pyplot-latex-font/39886/1 "2020-05-21T15:21:07Z")

</div>

I’m trying to recreate a plot I made in Python (attached) using PyPlot in Julia.  
I can’t seem to get the tick font and the x- and y- label fonts to match the ones in Python (Computer Modern I presume).

 ![J_ex](https://global.discourse-cdn.com/julialang/original/3X/1/9/1900ea9413066a55d9a86c8e7af0316c9f79252f.png) ![Pyth_ex1](https://global.discourse-cdn.com/julialang/original/3X/3/3/3359788ed8b8c35bc2dab9674fb0e9b51100f3b3.png)

Here are the RC settings:

```julia
rcParams = PyPlot.PyDict(PyPlot.matplotlib."rcParams")
rcParams["text.usetex"] = [true];
rcParams["mathtext.fontset"] = "cm";

```

I tried setting usetex to false but it doesn’t make a difference.  
I also tried these settings

```julia
PyPlot.matplotlib[:rc]("mathtext",fontset="cm") #computer modern font 
PyPlot.matplotlib[:rc]("font",family="serif",size=12)

```

but that doesn’t make a difference.

Any idea how to recreate the fonts on the Python plot using PyPlot?  
My Python Matplotlib settings are as follows:

```julia
plt.rc('text', usetex=True)
plt.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"]

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 22, 2020, 12:21am UTC](https://discourse.julialang.org/t/cant-seem-to-change-pyplot-latex-font/39886/2 "2020-05-22T00:21:33Z")

</div>

> [@KK\_JuliaNoob](#):
>
> `rcParams["text.usetex"] = [true];`

Shouldn’t this be `rcParams["text.usetex"] = true`? Why are you using an array `[true]` here?

> [@KK\_JuliaNoob](#):
>
> My Python Matplotlib settings are as follows:

The corresponding thing in Julia is:

```julia
plt.rc("text", usetex=true)
PyCall.PyDict(plt."rcParams")["text.latex.preamble"] = [raw"\usepackage{amsmath}"]

```

---

<div class="post-metadata">

**Author:** ![KK\_JuliaNoob](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@KK\_JuliaNoob](https://discourse.julialang.org/u/KK_JuliaNoob)\
**Post date:** [May 22, 2020, 12:28am UTC](https://discourse.julialang.org/t/cant-seem-to-change-pyplot-latex-font/39886/3 "2020-05-22T00:28:23Z")

</div>

Gah! That was it! (true instead of [true])  
I was confused because it was rendering some fonts fine, but the others were off.  
Thanks for catching the typo.
