質問編集履歴

3

誤字

2022/11/16 05:22

投稿

DaimaruY
DaimaruY

スコア1

test CHANGED
File without changes
test CHANGED
@@ -11,22 +11,23 @@
11
11
  import math
12
12
  v = 3
13
13
  for R in range(1,101): #xにかかる係数を少しずつ変化させたグラフを100枚
14
- a = 0.5
14
+ a = 0.5
15
- x, y = np.mgrid[-(a+a): a: 4001j, -a: a: 4001j]
15
+ x, y = np.mgrid[-(a+a): a: 4001j, -a: a: 4001j]
16
- f = '5.5*y**2 + ('+str(v) +'x + 1 - np.sqrt(abs(5.5y)))**2 - 1' #陰関数
16
+ f = '5.5*y**2 + ('+str(v) +'x + 1 - np.sqrt(abs(5.5y)))**2 - 1' #陰関数
17
- v = v + 0.02
17
+ v = v + 0.02
18
- fig = plt.figure()
18
+ fig = plt.figure()
19
- axis = fig.add_subplot(1,1,1)
19
+ axis = fig.add_subplot(1,1,1)
20
- axis.tick_params(axis='both', length=10, which='major')
20
+ axis.tick_params(axis='both', length=10, which='major')
21
- axis.tick_params(axis='both', length=5, which='minor')
21
+ axis.tick_params(axis='both', length=5, which='minor')
22
- axis.set_aspect('equal', 'box')
22
+ axis.set_aspect('equal', 'box')
23
- axis.set(xlim=(-(a+a), 0), ylim=(-a, a))
23
+ axis.set(xlim=(-(a+a), 0), ylim=(-a, a))
24
- axis.contour(x, y, eval(f),[0], colors="black") #ここで関数を描写
24
+ axis.contour(x, y, eval(f),[0], colors="black") #ここで関数を描写
25
- plt.axis('off') #軸や余白なしで保存したい為
25
+ plt.axis('off') #軸や余白なしで保存したい為
26
26
 
27
- axis.fill_between(??,??) #ここで何を入力すれば良いのでしょうか??
27
+ axis.fill_between(??,??) #ここで何を入力すれば良いのでしょうか??
28
28
 
29
- fig.savefig('2dplot_ex'+ str(R) + '.png', transparent=False, bbox_inches='tight',pad_inches = 0)
29
+ fig.savefig('2dplot_ex'+ str(R) + '.png', transparent=False,
30
+ bbox_inches='tight',pad_inches = 0)
30
31
 
31
32
  ### 試したこと
32
33
  axis.fill_between(??,??)の中身を一通り試しましたがうまくいきません、ご教授お願いしたいです。以下の画像を塗りつぶした画像を取得したいです。

2

誤字

2022/11/14 12:12

投稿

DaimaruY
DaimaruY

スコア1

test CHANGED
@@ -1 +1 @@
1
- [Python]Matplotlibを用いて、関数のグラフを塗りつぶした画像を取得したい
1
+ [Python]Matplotlibを用いて、関数のグラフを塗りつぶした画像を取得したい
test CHANGED
File without changes

1

誤字

2022/11/14 12:11

投稿

DaimaruY
DaimaruY

スコア1

test CHANGED
File without changes
test CHANGED
@@ -1,7 +1,7 @@
1
1
  初めての質問投稿なので至らない点があったら申し訳ございません。
2
2
 
3
3
  機械学習用サンプル画像をMatplotlibで取得しようと、いろいろ試行錯誤しましたがうまく塗りつぶした画像が出力できません。axis.fill_between()関数を用いましたが、出力画像に反映されません。
4
- 関数:f = '5.5*y**2 + ('+str(v) +'x + 1 - np.sqrt(abs(5.5y)))**2 - 1'とx=0が囲む領域を黒で塗りつぶしたいです。
4
+ 関数:f = '5.5*y**2 + ('+str(v) +'x + 1 - np.sqrt(abs(5.5y)))**2 - 1'とx=0が囲む領域を黒で塗りつぶしたいです。
5
5
  ### 該当のソースコード
6
6
 
7
7
  import numpy as np
@@ -13,7 +13,7 @@
13
13
  for R in range(1,101): #xにかかる係数を少しずつ変化させたグラフを100枚
14
14
  a = 0.5
15
15
  x, y = np.mgrid[-(a+a): a: 4001j, -a: a: 4001j]
16
- f = '5.5*y**2 + ('+str(v) +'x + 1 - np.sqrt(abs(5.5y)))**2 - 1' #関数
16
+ f = '5.5*y**2 + ('+str(v) +'x + 1 - np.sqrt(abs(5.5y)))**2 - 1' #関数
17
17
  v = v + 0.02
18
18
  fig = plt.figure()
19
19
  axis = fig.add_subplot(1,1,1)