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

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

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

no image

matplotlib で、凡例を表示する方法

データに label を関連付け、plt.legend() で凡例を表示する。 例 from matplotlib import pyplot as plt data_x = [25,26,2 …

no image

python3 で辞書からタプルを作成する

辞書に対して、items() メソッドを使うと、タプルを作成することができる。 例 cities = {‘東京’:1000,’大阪’:700, ‘広島’:100} for a,b in cities. …

no image

python3 でリストを結合する方法

2つのリストを結合して、「リストのリストを作りたい場合」と、「1つの長いリストを作りたい」場合がある。 それぞれ、次のようにする。 例 # リスト2つを用意 l_1 = [1,2,3] l_2 …

no image

matplotlib で、線の種類を変更する方法

「linestyle = 」として、線の種類を指定することができる設定の詳細は、次のリンクを参照。 https://matplotlib.org/stable/gallery/lines_bars_a …