目前正在尝试使用面向对象接口的matplotlib。我对这个工具还是新手
这是我想用matplotlib创建的图形(使用excel)的最终结果
下面是我写的代码
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
loaddf = pd.read_excel("C:\\SampleRevenue.xlsx")
#to get the row on number of tickets
count = loaddf.iloc[0]
#to get the total proceeds I get from sellling the ticket
vol = loaddf.iloc[1]
#The profit from tickets after deducting costs
profit = loaddf.iloc[2]
fig, ax = plt.subplots(figsize=(8, 4))
ax.barh(str(count), list(loaddf.columns.values))
当数据帧被转置时,
read_excel
会变得非常混乱。它期望第一行是列的标题,随后的每一行是下一个条目。(可选)第一列包含行标签。在这种情况下,必须将index_col=0
添加到read_excel
的参数中。如果在Excel中复制并粘贴转置所有内容,其工作方式可能如下:如果不转置Excel,则标题行将获取部分数据,这将导致“no numeric data to plot”消息
相关问题 更多 >
编程相关推荐