にmatplotlibのをアップグレードし、最新バージョン(4.3)、へアナコンダのPythonを更新
。 そして、私はそれらの変更のいくつかが本当に好きですが、私はそれらの変更のいくつかと一致していません。
したがって、上記のリンクに示唆したように、私は、いくつかの変更をした:
軸ラベルとしてラテックスを使用#%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
import scipy as sc
import matplotlib.pyplot as plt
import matplotlib
# http://matplotlib.org/users/dflt_style_changes.html
params = {'legend.fontsize': 18,
'axes.labelsize': 18,
'axes.titlesize': 18,
'xtick.labelsize' :12,
'ytick.labelsize': 12,
'mathtext.fontset': 'cm',
'mathtext.rm': 'serif',
'grid.color': 'k',
'grid.linestyle': ':',
'grid.linewidth': 0.5,
}
matplotlib.rcParams.update(params)
x = sc.linspace(0,100)
y = x**2
fig = plt.figure('Fig')
ax = fig.add_subplot(1, 1, 1)
lines = ax.semilogy(x, y)
ax.set_yticks([300], minor=True)
ax.yaxis.grid(True, which='minor')
ax.yaxis.set_minor_formatter(matplotlib.ticker.ScalarFormatter())
ax.tick_params(axis='y', pad=10)
ax.set_xlabel(r'$\mathrm{R_L}$')
ax.set_ylabel(r'$\sigma \int_l \; dx$')
#fig.savefig('./PNG/test.png', dpi=300, bbox_inches='tight')
、上記のコードのように、軸上の一貫性のないテキストで、図中の結果は、(下記参照画像)。以前の動作に(下の画像を参照)または一貫性のあるフォント方式に戻って取得する方法
?
EDIT: ラテックスバックエンドを使用して、私は良い結果を得ることができていますが、それは非常に遅いです。 とにかく、内部のバックエンドは一貫した出力を得ることができ、別のバックエンドに切り替えることは本当の解決策ではなく、より回避策であると思います。
#%matplotlib inline
#%matplotlib notebook
#%config InlineBackend.figure_format = 'svg'
import scipy as sc
import matplotlib.pyplot as plt
import matplotlib
# http://matplotlib.org/users/dflt_style_changes.html
params = {'legend.fontsize': 18,
'axes.labelsize': 18,
'axes.titlesize': 18,
'xtick.labelsize' :12,
'ytick.labelsize': 12,
'mathtext.fontset': 'cm',
'mathtext.rm': 'serif',
'grid.color': 'k',
'grid.linestyle': ':',
'grid.linewidth': 0.5,
}
matplotlib.rcParams.update(params)
matplotlib.rcParams.update({'text.usetex':True, 'text.latex.preamble':[r'\usepackage{amsmath, newtxmath}']})
x = sc.linspace(0,100)
y = x**2
fig = plt.figure('Fig')
ax = fig.add_subplot(1, 1, 1)
lines = ax.semilogy(x, y)
ax.set_yticks([300], minor=True)
ax.yaxis.grid(True, which='minor')
ax.yaxis.set_minor_formatter(matplotlib.ticker.ScalarFormatter())
ax.tick_params(axis='y', pad=10)
ax.set_xlabel(r'$\mathrm{R_L}$')
ax.set_ylabel(r'$\sigma \int_l \; dx$')
#fig.savefig('./PNG/test.png', dpi=300, bbox_inches='tight')
matplotlibの2との結果である:
古いバージョンの結果のプロットである(まだ少し異なる、多分
バックエンドラテックスを使用するにいくつかのラテックスの違いによる):
しかし、再び、望ましい結果は、あなたが提供したリンクからは、図2
組み込み数学レンダリングエンジン(mathtext)を使用するときのデフォルトの数学フォントが「コンピュータモダン」(LaTeX風)から「DejaVu Sans」に変更されました。言い換えれば、_default_ビヘイビアは、下のグラフのようなサンセリフフォントでなければなりません。 '' mathtext.rm 'のように見えます:' serif ''が原因で、問題を解決する必要があります。 – roganjosh
私はその変更を試みましたが、出力は同じです。 – Alex
私は複製できませんでしたので、matplotlibをアップグレードしようとしましたが、今は 'numpy'のインストールを非常に有効に削除しましたので、何もテストできません。しかし、数学のフォントセクションには '' mathtext.fontset ':' cm''と書かれているので、それも削除するかもしれません。私はその行が何をしているのか分からない。 – roganjosh