PyPlot - Axis label, italic format for the symbol only


#1

Dear all, in PyPlot, do you know how to format the symbol to italic only, the other words should be normal.
For example: x label “Grading index IG”. Then I would like IG to be italic.


#2

This should work:

xlabel = "grading index \$I_G\$"

I use Pyplot through Plots.jl so an MWE would be:

using Plots; pyplot()
plot(rand(100), xlabel = "grading index \$I_G\$"

#3

Thank you very much! It worked perfectly


#4

Excuse me, do you know any way to keep the same font of the italic symbol, as the other?
In this case, do you how to we keep the same Times New Roman font?


#5

It depends a bit on which fonts PyPlot can access, but generally the way to change it would be

plot(rand(100), xlabel = "grading index \$I_G\$", guidefont=font("serif"))

#6

In Julia, the command is like this:

plot(rand(100)); xlabel( "grading index \$I_G\$", fontname="Times New Roman")

but, then the font of “grading index” is Times New Roman, but the font of I_G is not changed with this syntax


#7

Ah sorry you were just asking about I_G - this is rendered as LaTeX, so you could try some LaTeX commands for setting the font.