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 でリストを結合する方法

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

no image

matplotlib で、グラフのタイトルに上付き文字を入力する方法

数学記号などで、グラフのタイトルに上付きの文字を入力したい場合がある。 その場合は次のように書いて設定できる。 例 import numpy as np from matplotlib import …

no image

python におけるシフト演算子(<< と >> )の使い方

32 = 2^5 なので、 << 1 とすると数値は2倍され、 >> 1 とすると数値が2分の1となる。 例 print(32 << 0) print(32 << …

no image

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

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

no image

gnuplot で、グラフの形を正方形にする方法

set size square または、その省略形で set size sq というコマンドを使えば正方形の中にグラフを描くことができる。 例 set size square plot cos(x) …

S