Python?pyecharts繪制折線圖詳解
一、繪制折線圖
import seaborn as sns import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt %matplotlib inline plt.rcParams['font.sans-serif']=['Microsoft YaHei'] # 用來正常顯示中文標(biāo)簽 plt.rcParams['axes.unicode_minus']=False # 用來正常顯示負(fù)號 from datetime import datetime plt.figure(figsize=(16,10)) import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.faker import Faker from pyecharts.charts import Bar import os from pyecharts.options.global_options import ThemeType
# 讀入數(shù)據(jù) cnbodfgbsort=pd.read_csv("cnbodfgbsort.csv")
得到的cnbodfgbsort數(shù)據(jù):
import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.faker import Faker c = ( Line() .add_xaxis(cnbodfgbsort.TYPE.tolist()) #X軸 .add_yaxis("票價(jià)",cnbodfgbsort.PRICE.tolist()) #Y軸 .add_yaxis("人次",cnbodfgbsort.PERSONS.tolist()) #Y軸 .set_global_opts(title_opts=opts.TitleOpts(title="電影票價(jià)與人次")) #標(biāo)題 ) c.render_notebook() # 顯示
二、添加最小值最大值平均值
import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.faker import Faker c = ( Line() .add_xaxis(cnbodfgbsort.TYPE.tolist()) .add_yaxis("票價(jià)",cnbodfgbsort.PRICE.tolist()) .add_yaxis("人次",cnbodfgbsort.PERSONS.tolist(), markpoint_opts=opts.MarkPointOpts( data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ] ), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")] ),) .set_global_opts(title_opts=opts.TitleOpts(title="電影票價(jià)與人次")) ) c.render_notebook()
三、豎線提示信息
tooltip_opts=opts.TooltipOpts(trigger="axis")
四、顯示工具欄
toolbox_opts=opts.ToolboxOpts(is_show=True)
五、實(shí)心面積填充
.set_series_opts( areastyle_opts=opts.AreaStyleOpts(opacity=0.5), # 透明度 label_opts=opts.LabelOpts(is_show=False), # 是否顯示標(biāo)簽 )
六、是否跳過空值
import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.faker import Faker y = Faker.values() y[3], y[5] = None, None c = ( Line() .add_xaxis(Faker.choose()) .add_yaxis("商家A", y, is_connect_nones=True) .set_global_opts(title_opts=opts.TitleOpts(title="Line-連接空數(shù)據(jù)")) .render("line_connect_null.html") )
如下圖:y[3],y[5]數(shù)據(jù)都是空值,如果直接顯示的話,圖表會出錯(cuò)
# 使用這個(gè)參數(shù)來跳過空值,避免折現(xiàn)斷掉 is_connect_nones=True
import pyecharts.options as opts from pyecharts.charts import Line from pyecharts.faker import Faker y = Faker.values() y[3], y[5] = None, None c = ( Line() .add_xaxis(Faker.choose()) .add_yaxis("商家A", y, is_connect_nones=True) .set_global_opts(title_opts=opts.TitleOpts(title="Line-連接空數(shù)據(jù)")) ) c.render_notebook()
七、折線光滑化
is_smooth=True
八、多X軸
參考官網(wǎng):》multiple_x_axes
九、階梯圖
is_step=True
以上就是Python pyecharts繪制折線圖詳解的詳細(xì)內(nèi)容,更多關(guān)于Python pyecharts折線圖的資料請關(guān)注腳本之家其它相關(guān)文章!
- Vue2利用echarts繪制折線圖,餅圖和大圖
- echarts折線圖流動(dòng)特效的實(shí)現(xiàn)全過程(非平滑曲線)
- vue+echarts繪制折線圖、柱狀圖和扇形圖教程
- Vue+Echarts實(shí)現(xiàn)繪制動(dòng)態(tài)折線圖
- vue+echarts實(shí)帶漸變效果的折線圖
- vue使用echarts實(shí)現(xiàn)折線圖
- vue使用ECharts實(shí)現(xiàn)折線圖和餅圖
- Echarts基本入門之柱狀圖、折線圖通用配置
- echarts折線圖月份數(shù)據(jù)不足自動(dòng)補(bǔ)0和日期達(dá)到數(shù)據(jù)連續(xù)的效果(最新推薦)
相關(guān)文章
Python機(jī)器學(xué)習(xí)入門(一)序章
這篇文章主要介紹了Python機(jī)器學(xué)習(xí)入門知識,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08Python中的Pandas?時(shí)間函數(shù)?time?、datetime?模塊和時(shí)間處理基礎(chǔ)講解
Python?中提供了對時(shí)間日期的多種多樣的處理方式,主要是在?time?和?datetime?這兩個(gè)模塊里,這篇文章主要介紹了Python中的Pandas?時(shí)間函數(shù)?time?、datetime?模塊和時(shí)間處理基礎(chǔ),需要的朋友可以參考下2023-03-03pycharm利用pyspark遠(yuǎn)程連接spark集群的實(shí)現(xiàn)
由于工作需要,利用spark完成機(jī)器學(xué)習(xí)。因此需要對spark集群進(jìn)行操作。所以利用pycharm和pyspark遠(yuǎn)程連接spark集群。感興趣的可以了解一下2021-05-05使用python實(shí)現(xiàn)哈希表、字典、集合操作
這篇文章主要介紹了使用python實(shí)現(xiàn)哈希表、字典、集合操作,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12Python中str.format()和f-string的使用
本文主要介紹了Python中str.format()和f-string的使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02