視覺化分析四
一.今日內容
程式設計,在乙個子圖系統中,用兩個水平排列的折線型子圖畫出m市和n市
2023年1
至3月的上映電影的票房總收入趨勢,要求將輸出的完整子圖儲存成影象檔案
ans0304.jpg;程式源**儲存成
ans0304.py,要求:
左子圖為m市票房總收入趨勢,右子圖為
n市票房總收入趨勢,
y軸表示票房收入,單位為「萬元」,
x軸表示時間,以「0、
1、2、
3」作為刻度值;
兩子圖均有說明子圖內容的標題(如:m 2016 1-3 bor);
將以下6個資料分
2行按順序存入
ans0304.dat檔案中,要求
ans0305.dat只包含浮點型資料,以萬元為單位,保留
6位小數,需要儲存的票房資料是:第1行
3個資料,按順序分別是
m市電影市場
2023年1
、2、3
月票房總收入,第
2行三個資料,按順序分別是
n市電影市場
2023年1
、2、3
月票房總收入,同行資料以英文逗號分隔,檔案樣例如下:
2023.123456,2000.654321,1988.123456
2303.123456,2100.654321,17898.123456
二.內容原始碼
#author:ljk
#-*- coding:utf-8 -*-
import pandas as pd
import numpy as np
import datetime
import matplotlib.pyplot as plt
csv_file = pd.read_csv('film_log3.csv',sep=';',header=none)
csv_file.fillna(0,inplace=true)
csv_file = csv_file.drop_duplicates()
def get_city(city_name):
city = csv_file[csv_file[8].isin([city_name])]
city = city[city[2] > '2016.1.1']
return city.set_index(np.arange(len(city)))
def get_days(data):
month1 =
month2 =
month3 =
for i in range(len(data)):
total = float(data[7][i].replace('票房(萬)
', ''))
start_time = datetime.datetime.strptime(data[1][i],"%y.%m.%d")
end_time = datetime.datetime.strptime(data[2][i],"%y.%m.%d")
days = (end_time - start_time).days + 1
a_day = total / days
if data[2][i] >= '2016.1.1' and data[2][i] < '2016.2.1':
month_1 = (end_time - datetime.datetime.strptime('2016.1.1','%y.%m.%d')).days + 1
m_total1 = month_1 * a_day
elif data[2][i] >= '2016.2.1' and data[2][i] < '2016.3.1':
month_2 = (end_time - datetime.datetime.strptime('2016.2.1', '%y.%m.%d')).days + 1
m_total_21 = 31 * a_day
m_total2 = month_2 * a_day
elif data[2][i] >= '2016.3.1' and data[2][i] < '2016.4.1':
month_3 = (end_time - datetime.datetime.strptime('2016.3.1', '%y.%m.%d')).days + 1
m_total31 = 31 * a_day
m_total32 = 29 * a_day
m_total3 = month_3 * a_day
return month1,month2,month3
def main(city_name):
city = get_city(city_name)
city_m = get_days(city)
city_m1 = sum(city_m[0])
city_m2 = sum(city_m[1])
city_m3 = sum(city_m[2])
return [city_m1,city_m2,city_m3]
m_city = main('武漢
')n_city = main('長沙
三.遇到問題
主要的問題還是視覺化中 matplotlib各個影象的畫法以及影象資料的顯示
四.解決方案
根據之前寫的小程式的簡單影象以及例題答案等進行參考來畫出影象
IGV BWA Samtool的視覺化分析過程。
1.首先使用bwa進行reads比對,結果會產生sam檔案。2.對結果檔案進行視覺化的時候必須要注意,igv並不是支援所有的檔案格式,所以要通過samtool進行格式轉換。3.所以比對後的sam檔案不能夠進行直接視覺化,首先通過samtool軟體進行格式轉化為bam檔案,samtools view ...
Excel視覺化分析方法對比分析
本文為學習天善學院李奇老師用資料說話 excel bi商業智慧型分析零基礎精講課程筆記。excel常用的視覺化分析方法中有,對比分析 結構分析 透視分析 其他分析。常言道,不比不知道,一比嚇一跳,對比分析可以幫我們達到 知己知彼,百戰不殆 的目的,是商業分析中最為常見和重要的方法。對比分析主要有如下...
什麼是資料視覺化分析平台
資料視覺化平台是通過三維表示技術來表達複雜的資訊,實現海量資料的立體體現。視覺化技術借鑑人腦的視覺顯示能力,通過挖掘重要資料之間的關係,揭示資料中隱藏的關聯和發展趨勢,從而提高資料的使用效率。視覺化平台使人們不再侷限於傳統的關係資料表來分析資料資訊,而是以更加直觀的方式從視覺的角度觀察資料資訊。大資...