matplotlib python3

matplotlib でグラフの背景の色を変える方法(facecolor)

投稿日:

次のように、axes で facecolor を変更すればよい。

from matplotlib import pyplot as plt

x = [2,7,8]
y = [7,1.2,3]

fig, ax = plt.subplots()
size = 300
ax.scatter(x,y,size)
ax.set_xlim([0,10])
ax.set_ylim([0,10])
ax.set_facecolor('silver')
plt.show()

結果

-matplotlib, python3
-,

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

matplotlib で、縦横の罫線を引く方法

破線をカスタマイズする方法 以下では、dashes = [5,2,2,2] で、線5・空白2・線2・空白2の破線を指定している。 詳しくは次を参照。 https://matplotlib.org/st …

no image

pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。

next() を使う。 例 my_arr = [‘春’,’夏’,’秋’,’冬’] my_iter = iter(my_arr) print(next(my_iter,’なし’)) print(next …

no image

matplotlib でグラフ表示ウィンドウの画面上の位置を自由に設定する方法

matplotlib.use(‘TkAgg’) としておき、 get_current_fig_manager().window.wm_geometry(“+20+50”) として、(+20+50)のと …

no image

python3 でランダムな整数の配列を作る方法

random モジュールを使う。randint() の引数で、配列の最小値と最大値を指定できる。 例 import random random_arr = [random.randint(-2 …

no image

python3 でタプルを指定した要素で順に並び替える

タプルを、指定した要素で並び替えることができる。「key=lambda x 」で、引数 x を指定。lambda は無名関数を表す。 例 record = [(‘織田信長’, 1534, 15 …