質問

したがって、次のことはできないようです(エラーが発生します。 axes はありません set_linewidth 方法):

axes_style = {'linewidth':5}
axes_rect = [0.1, 0.1, 0.9, 0.9]

axes(axes_rect, **axes_style)

代わりに次の古いトリックを使用する必要があります。

rcParams['axes.linewidth'] = 5 # set the value globally

... # some code

rcdefaults() # restore [global] defaults

簡単/クリーンな方法はありますか(設定できるかもしれません) x- そして y- 軸パラメータを個別に設定するなど)?

追伸いいえの場合、その理由は何ですか?

役に立ちましたか?

解決

それはコメントで説明されているように、

上記の答えは、動作しません。私は棘を使用することをお勧めします。

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

# you can change each line separately, like:
#ax.spines['right'].set_linewidth(0.5)
# to change all, just write:

for axis in ['top','bottom','left','right']:
  ax.spines[axis].set_linewidth(0.5)

plt.show()
# see more about spines at:
#http://matplotlib.org/api/spines_api.html
#http://matplotlib.org/examples/pylab_examples/multiple_yaxis_with_spines.html

他のヒント

plt.setp(ax.spines.values(), linewidth=5)

はい、これを行う簡単でクリーンな方法があります。

「」を呼び出しますアキシュライン' そして 'アクスブライン' 軸インスタンスからのメソッドは、MPL ドキュメントで承認されているテクニックのようです。

いずれにしても、これはシンプルであり、軸の外観をきめ細かく制御できます。

たとえば、このコードはプロットを作成し、X 軸を緑色に色付けし、X 軸の線幅をデフォルト値の「1」から値「4」に増加します。y 軸が赤色になり、y 軸の線幅が「1」から「8」に増加します。

from matplotlib import pyplot as PLT
fig = PLT.figure()
ax1 = fig.add_subplot(111)

ax1.axhline(linewidth=4, color="g")        # inc. width of x-axis and color it green
ax1.axvline(linewidth=4, color="r")        # inc. width of y-axis and color it red

PLT.show()

axhline/axvline 関数は追加の引数を受け入れるので、美的に望むことは何でもできるはずです。特に ~matplotlib.lines.Line2D プロパティは有効な kwargs (例: 'alpha'、'linestyle'、capstyle、結合スタイル)。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top