VOOZH about

URL: https://qiita.com/kaizen_nagoya/items/13299f036b8795fc3048

⇱ 今日のpython error TypeError: only length-1 arrays can be converted to Python scalars #Python - Qiita


👁 Image
0

Go to list of users who liked

0

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@kaizen_nagoya(Dr. Kiyoshi Ogawa)

今日のpython error TypeError: only length-1 arrays can be converted to Python scalars

0
Posted at

プログラムちょい替え(6)pyhon sin 描画
https://qiita.com/kaizen_nagoya/items/2702bdf0b89b3d841921

で、さらに直そうとして次のようなプログラムにしてみた。

sina.py
import matplotlib.pyplot as plt
import numpy as np
import math 

# データ生成
x = np.linspace(0, 3.2, 10)
y = math.sin(x)

# プロット領域(Figure, Axes)の初期化
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(133)

# 棒グラフの作成
ax.scatter( x, y)

# 水平線、垂直線を入れる
ax.axhline(0)

plt.show()

実行してみる。

macOS
$python sin.py
Traceback (most recent call last):
 File "sin.py", line 7, in <module> y = math.sin(x)
TypeError: only length-1 arrays can be converted to Python scalars

ごめん。

0

Go to list of users who liked

0
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0

Go to list of users who liked

0