好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > python讀取excel數據并且畫圖的實現示例

python讀取excel數據并且畫圖的實現示例

熱門標簽:鎮江人工外呼系統供應商 深圳網絡外呼系統代理商 高德地圖標注字母 柳州正規電銷機器人收費 騰訊地圖標注有什么版本 千呼ai電話機器人免費 外呼系統前面有錄音播放嗎 400電話辦理費用收費 申請辦個400電話號碼

一,要讀取的數據的格式:

二,數據讀取部分:

b站視頻參考:https://www.bilibili.com/video/BV14C4y1W7Nj?t=148

# 1930
workbook=xlrd.open_workbook('1930.xlsx')
sheet= workbook.sheet_by_index(0)
A1=[]
B1=[]
# sheet.cell_value(i,0):第i行的第0個元素
for i in range(1,sheet.nrows):
 A1.append(sheet.cell_value(i,0))
 B1.append(sheet.cell_value(i,1))
 
if len(A1)!=len(B1):
 print("False")
drawBar(A1,B1,1930)
 

三,畫圖函數

1. def drawBar(Music_genre,singer_num,year)

參數介紹

參數名 參數含義
Music_genre 音樂流派名稱list
singer_num 音樂流派對應音樂家數量list
year 讀的文件的年份(因為源代碼是從1840到2020的)

def drawBar(Music_genre,singer_num,year):
 arr_len=len(Music_genre)
 # 由循環得到一個字典,key是音樂流派,value是這個音樂流派對應的音樂家的數量
 i=0
 dict_music_singer={}
 while iarr_len:
 dict_music_singer[Music_genre[i]]=singer_num[i]
 i=i+1
 
	# 注釋1
 pyplot.bar(x=0, bottom=range(arr_len), height=0.3, width=singer_num, orientation="horizontal")
 # 注釋2
 pyplot.yticks(range(arr_len),Music_genre)
 # 加title,展示圖像
 pyplot.title(year)
 pyplot.show()
 
 ...
 ...
 drawBar(A1,B1,1930)
 

注釋1:

"""
 水平條形圖,需要修改以下屬性
 orientation="horizontal"
"""
import numpy as np
import matplotlib.pyplot as plt
 
# 數據
N = 5
x = [20, 10, 30, 25, 15]
y = [0,1,2,3,4]
 
# 繪圖 x= 起始位置, bottom= 水平條的底部(左側), y軸, height 水平條的寬度, width 水平條的長度
p1 = plt.bar(x=0, bottom=y, height=0.5, width=x, orientation="horizontal")
pyplot.bar(range(arr_len),singer_num,align='center')
pyplot.bar(x=0, bottom=range(arr_len), height=0.5, width=singer_num, orientation="horizontal")
# 展示圖形
plt.show()

注釋2:plt.xticks的第一個參數和plt.plot的第一個參數一樣,第二個參數是和第一個參數相同長度的list此例中用來代替橫坐標

import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 6]
labels = ['Frogs', 'Hogs', 'Bogs', 'Slogs']
 
plt.plot(x, y)
# You can specify a rotation for the tick labels in degrees or with keywords.
plt.xticks(x, labels, rotation='vertical')
# Pad margins so that markers don't get clipped by the axes
plt.margins(0.2)
# Tweak spacing to prevent clipping of tick-labels
plt.subplots_adjust(bottom=0.15)
plt.show()

1.1 效果:

1.2 完整代碼

import pandas as pd
import numpy as np 
import xlrd
from matplotlib import pyplot
def drawBar(Music_genre,singer_num,year):
 arr_len=len(Music_genre)
 
 i=0
 dict_music_singer={}
 while iarr_len:
 dict_music_singer[Music_genre[i]]=singer_num[i]
 i=i+1
 #pyplot.bar(range(arr_len),singer_num,align='center')
 pyplot.bar(x=0, bottom=range(arr_len), height=0.3, width=singer_num, orientation="horizontal")
 pyplot.yticks(range(arr_len),Music_genre)
 pyplot.title(year)
 pyplot.show()
 
 
# 1930
workbook=xlrd.open_workbook('1930.xlsx')
sheet= workbook.sheet_by_index(0)
A1=[]
B1=[]
for i in range(1,sheet.nrows):
 A1.append(sheet.cell_value(i,0))
 B1.append(sheet.cell_value(i,1))
 
if len(A1)!=len(B1):
 print("False")
drawBar(A1,B1,1930)
 
 
 
# 1940
workbook=xlrd.open_workbook('1940.xlsx')
sheet= workbook.sheet_by_index(0)
A2=[]
B2=[]
for i in range(1,sheet.nrows):
 A2.append(sheet.cell_value(i,0))
 B2.append(sheet.cell_value(i,1))
 
if len(A2)!=len(B2):
 print("False")
drawBar(A2,B2,1940)
 
 
 
# 
workbook=xlrd.open_workbook('1950.xlsx')
sheet= workbook.sheet_by_index(0)
A3=[]
B3=[]
for i in range(1,sheet.nrows):
 A3.append(sheet.cell_value(i,0))
 B3.append(sheet.cell_value(i,1))
 
if len(A3)!=len(B3):
 print("False")
drawBar(A3,B3,1950)
 
 
 
# 6
workbook=xlrd.open_workbook('1960.xlsx')
sheet= workbook.sheet_by_index(0)
A4=[]
B4=[]
for i in range(1,sheet.nrows):
 A4.append(sheet.cell_value(i,0))
 B4.append(sheet.cell_value(i,1))
 
if len(A4)!=len(B4):
 print("False")
drawBar(A4,B4,1960)
 
 
 
 
# 
workbook=xlrd.open_workbook('1970.xlsx')
sheet= workbook.sheet_by_index(0)
A5=[]
B5=[]
for i in range(1,sheet.nrows):
 A5.append(sheet.cell_value(i,0))
 B5.append(sheet.cell_value(i,1))
 
if len(A5)!=len(B5):
 print("False")
drawBar(A5,B5,1970)
 
 
 
 
# 
workbook=xlrd.open_workbook('1980.xlsx')
sheet= workbook.sheet_by_index(0)
A6=[]
B6=[]
for i in range(1,sheet.nrows):
 A6.append(sheet.cell_value(i,0))
 B6.append(sheet.cell_value(i,1))
 
if len(A6)!=len(B6):
 print("False")
drawBar(A6,B6,1980)
 
 
 
 
# 9
workbook=xlrd.open_workbook('1990.xlsx')
sheet= workbook.sheet_by_index(0)
A7=[]
B7=[]
for i in range(1,sheet.nrows):
 A7.append(sheet.cell_value(i,0))
 B7.append(sheet.cell_value(i,1))
 
if len(A7)!=len(B7):
 print("False")
drawBar(A7,B7,1990)
 
 
 
 
# 2000
workbook=xlrd.open_workbook('2000.xlsx')
sheet= workbook.sheet_by_index(0)
A8=[]
B8=[]
for i in range(1,sheet.nrows):
 A8.append(sheet.cell_value(i,0))
 B8.append(sheet.cell_value(i,1))
 
if len(A8)!=len(B8):
 print("False")
drawBar(A8,B8,2000)
 
 
 
 
# 
workbook=xlrd.open_workbook('2010.xlsx')
sheet= workbook.sheet_by_index(0)
A9=[]
B9=[]
for i in range(1,sheet.nrows):
 A9.append(sheet.cell_value(i,0))
 B9.append(sheet.cell_value(i,1))
 
if len(A9)!=len(B9):
 print("False")
drawBar(A9,B9,2010)
 
 
 
 
# # 
# workbook=xlrd.open_workbook('2020.xlsx')
# sheet= workbook.sheet_by_index(0)
# A2=[]
# B2=[]
# for i in range(1,sheet.nrows):
# A2.append(sheet.cell_value(i,0))
# B2.append(sheet.cell_value(i,1))
 
# if len(A2)!=len(B2):
# print("False")
# drawBar(A2,B2,2020)
 
 
 
 
 
 

以上就是python讀取excel數據并且畫圖的實現示例的詳細內容,更多關于python讀取excel數據并且畫圖的資料請關注腳本之家其它相關文章!

您可能感興趣的文章:
  • python 利用openpyxl讀取Excel表格中指定的行或列教程
  • Python讀取pdf表格寫入excel的方法
  • python excel和yaml文件的讀取封裝
  • python讀取excel數據繪制簡單曲線圖的完整步驟記錄
  • python在CMD界面讀取excel所有數據的示例
  • Python讀取Excel一列并計算所有對象出現次數的方法
  • python3:excel操作之讀取數據并返回字典 + 寫入的案例
  • 解決python pandas讀取excel中多個不同sheet表格存在的問題
  • Python matplotlib讀取excel數據并用for循環畫多個子圖subplot操作
  • python3 循環讀取excel文件并寫入json操作

標簽:郴州 海南 烏蘭察布 平頂山 大慶 烏蘭察布 合肥 哈爾濱

巨人網絡通訊聲明:本文標題《python讀取excel數據并且畫圖的實現示例》,本文關鍵詞  python,讀取,excel,數據,并且,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《python讀取excel數據并且畫圖的實現示例》相關的同類信息!
  • 本頁收集關于python讀取excel數據并且畫圖的實現示例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 天美麻豆果冻| 嗯啊灬别停啊灬用力灬快动漫| 国产精品国产三级国产| bt天堂国产亚洲欧美在线 | 武林第一美妇肉枪黄蓉| 久久99精品久久久久久国产越南| 最近好看的2019免费大全电影| 亚洲girl欣赏pics大全| 中国女人内谢69ⅩXXX麻豆| 艳母在线观| 成人漫画羞羞漫画入口| 看全免费的一级毛片| brazzers720高清欧美| 鄄城县| 男人激烈吮乳吃奶嘬奶头网站| 巨人观图片(胆小莫进)| 国产精品福利在线观看免费不卡 | 男人激烈吮乳吃奶嘬奶头电影| 齐天大性之9战观音bd| 国产欧美日韩一区| 秋霞电影网理论片久久| 国精产品一区一区三区mba下载 | 国产免费又黄又爽又色毛| 婷婷精品国产一区二区三区日韩| 亚洲精品www久久久久久软件| 嗯~啊别揉我奶头秘?黄漫| 农村妇女偷人高潮人人人| 亚洲精品国产成人片在线观看一区二区三区| 99久天堂AV在线播放软件| 色欲激情k8经典在线观看| 亚洲日韩精品高潮无码久久岛国久| 最新理伦片EEUSS影院播放| 欧美成人免费夜夜黄啪啪| 日本色图视频| 凸偷窥wc女厕学生在洗澡| 军警雄液by肉汁巴文| 日本三级午夜| 亚洲综合国产| 舒淇三级大全视频在线观看| videomakelove性欧美高清| 我要看逼逼|