matplotlib python3

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

投稿日:

破線をカスタマイズする方法

以下では、dashes = [5,2,2,2] で、線5・空白2・線2・空白2の破線を指定している。

詳しくは次を参照。

https://matplotlib.org/stable/gallery/lines_bars_and_markers/line_demo_dash_control.html

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.grid(True, dashes=[5,2,2,2])
plt.show()

結果

-matplotlib, python3
-,

執筆者:


comment

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

関連記事

no image

matplotlib で散布グラフを描く方法

pyplt.scatter を使って散布グラフを描くことができる。 点の色は、点ごとに変えることができる。 下の例では color の配列で点の色を指定している。 例 from matplotlib …

no image

python3 で整数の割り算、商と余りを求める方法

floor divisionを使う。 例 a = 15 // 7 b = 15 % 7 print(a) print(b) 結果 2 1

no image

matplotlib のプロットスクリプト内で計算する方法

gnuplot の場合 gnuplot では、plot “data.txt” u 1:($2*2)などと書くと、 数値を加工(データ値を使った計算)を行った結果をグラフ化するこ …

no image

python3 でクラス内からだけアクセスするメソッドを作る方法

1.メソッド内でメソッドを定義する2.メソッド最初にアンダースコアをつける(慣習)例: def _some_internal_func(self): … このうち、2.のメソッド名先頭にアンダース …

no image

matplotlib で、グラフ内に注釈ラベルをつける方法

annotate を使う 例 import numpy as np import matplotlib.pyplot as plt ax = plt.figure().add_subplot() th …