【发布时间】:2018-11-13 19:13:21
【问题描述】:
虽然有很多关于此错误的主题,但我找不到任何可以帮助我的解决方案。我的 .csv Excel 文件中有标有底部、左侧和右侧的标题,当我尝试绘制它们时,我得到一个无法将字符串转换为 由于这些标题导致的文本错误。我怎么能解决这个问题?
import matplotlib.pyplot as plt
import numpy as np
# Read the input data only once
Bottom, Left, Right = np.loadtxt ("C:Data 2.csv", delimiter=",", skiprows=1, unpack=True)
# Plot in the first axis
ax1.plot(Bottom, Left, label='Pressure/area', color='b')
plt.show()
这是文件的样子:
【问题讨论】:
-
当询问加载文本文件时遇到的错误时,您需要提供文本文件(它的最小版本)和特定于该问题的代码(不是一些不相关的绘图命令)。见minimal reproducible example。
标签: python python-2.7 numpy matplotlib graph