質問編集履歴

2

@「試したこと」を加筆しました

2024/04/15 07:31

投稿

yyicp
yyicp

スコア70

test CHANGED
File without changes
test CHANGED
@@ -78,4 +78,25 @@
78
78
  ### 試したこと
79
79
  ネットで色々調べましたが、よく分かりませんでした。
80
80
 
81
+ 「該当のソースコード」の48行目を
82
+ ax2 = plt.contour(x,y,z,cmap='jet',levels=levels2,colors=['purple', 'r', 'y', 'g', 'b'])
83
+ としてみましたが、下記のようなエラーメッセージが出てしまいました。
84
+ ```
85
+ Traceback (most recent call last):
86
+ File "・・・\testCV228-2.py", line 69, in <module>
87
+ ax2 = plt.contour(x,y,z,cmap='jet',levels=levels2,colors=['purple', 'r', 'y', 'g', 'b'])
88
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
89
+ File "・・・\Python311\Lib\site-packages\matplotlib\pyplot.py", line 2527, in contour
90
+ __ret = gca().contour(
91
+ ^^^^^^^^^^^^^^
92
+ File "・・・\Python311\Lib\site-packages\matplotlib\__init__.py", line 1461, in inner
93
+ return func(ax, *map(sanitize_sequence, args), **kwargs)
94
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95
+ File "・・・\Python311\Lib\site-packages\matplotlib\axes\_axes.py", line 6449, in contour
96
+ contours = mcontour.QuadContourSet(self, *args, **kwargs)
97
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98
+ File "・・・\Python311\Lib\site-packages\matplotlib\contour.py", line 756, in __init__
99
+ raise ValueError('Either colors or cmap must be None')
100
+ ValueError: Either colors or cmap must be None
81
101
 
102
+ ```

1

文章の修正

2024/04/15 06:19

投稿

yyicp
yyicp

スコア70

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
  「該当のソースコード」を実行すると、以下の図が出てきます。(test1.png)
5
5
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-04-15/45a12e1f-6893-4c0f-985d-a6868e9b3885.png)
6
6
 
7
- ここで、等高線を描きたい量(displacement)は整数値しかとらないことに気づいたため、等高線をcontourfからcontourに変更しようと思いました。(48行目の[リンク内容](url)contourf→contour)
7
+ ここで、等高線を描きたい量(displacement)は整数値しかとらないことに気づいたため、等高線をcontourfからcontourに変更しようと思いました。(48行目のcontourf→contour)
8
8
  その実行結果が以下の図です。(test2.png)
9
9
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-04-15/7f274a12-ef39-44ff-a81a-58d43ffb3988.png)
10
10