# interactive-visual **Repository Path**: ALYFUxixi/interactive-visual ## Basic Information - **Project Name**: interactive-visual - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-09-27 - **Last Updated**: 2024-10-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Untitled16
In [5]:
from pyecharts import options as opts
from pyecharts.charts import Boxplot
In [6]:
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar


def bar_base() -> Bar:
    c = (
        Bar()
        .add_xaxis(Faker.choose())
        .add_yaxis("商家A", Faker.values())
        .add_yaxis("商家B", Faker.values())
        .set_global_opts(title_opts=opts.TitleOpts(title="Bar-基本示例", subtitle="我是副标题"))
    )
    return c
In [8]:
a = bar_base()
a.render_notebook()
Out[8]:
In [9]:
实例A = bar_base()
实例A.render_notebook()
Out[9]:
In [11]:
import pandas as pd
import csv, os
data = pd.read_csv('C:/Users/Alyfu/Desktop/oecd_carbon_emissions_data.csv',index_col='Country')             #读取csv文件
In [12]:
data
Out[12]:
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 ... 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017
Country
United States 6371000.54 6315615.19 6424934.36 6532069.60 6624835.79 6710067.3 6907699.05 6968461.97 7032526.01 7071461.46 ... 7160600.81 6709369.15 6938591.68 6787419.03 6545969.33 6710218.18 6759995.63 6623775.48 6492267.43 6456718.19
European Union (28 countries) 5649529.34 5555045.95 5379830.54 5281540.39 5255297.27 5308544.0 5418671.89 5326316.82 5281519.48 5172643.92 ... 5046999.43 4681900.46 4783627.79 4626382.21 4563064.71 4468920.46 4297635.77 4327313.20 4303391.87 4323163.15

2 rows × 28 columns

In [48]:
x轴 = data.columns.values
x轴 = data.columns.values[-10:]
x轴
Out[48]:
array(['2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015',
       '2016', '2017'], dtype=object)
In [49]:
美国 = list(data.loc['United States'].values)[-10:]
美国
Out[49]:
[7160600.81,
 6709369.15,
 6938591.68,
 6787419.03,
 6545969.33,
 6710218.18,
 6759995.63,
 6623775.48,
 6492267.43,
 6456718.19]
In [50]:
欧洲 = list(data.loc['European Union (28 countries)'].values)[-10:]
欧洲
Out[50]:
[5046999.43,
 4681900.46,
 4783627.79,
 4626382.21,
 4563064.71,
 4468920.46,
 4297635.77,
 4327313.2,
 4303391.87,
 4323163.15]
In [40]:
from pyecharts import options as opts
from pyecharts.charts import Bar
In [51]:
def bar_base() -> Bar:
    c = (
        Bar()
        .add_xaxis(['2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015',
       '2016', '2017'])
        .add_yaxis("美", 美国)
        .add_yaxis("欧", 欧洲)
        .set_global_opts(title_opts=opts.TitleOpts(title="二氧化碳排放量", subtitle="欧美对比"))
    )
    return c
In [52]:
b = bar_base()
b.render_notebook()
Out[52]:
In [53]:
def bar_base() -> Bar:
    c = (
        Bar()
        .add_xaxis((['2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015',
       '2016', '2017']))
        .add_yaxis("美", 美国)
        .add_yaxis("欧", 欧洲)
        .set_global_opts(title_opts=opts.TitleOpts(title="二氧化碳排放量", subtitle="欧美对比"))
    )
    return c
b = bar_base()
b.render_notebook()
Out[53]:
In [54]:
                                                                                                                                    import pyecharts.options as opts
from pyecharts.faker import  Faker
from pyecharts.charts import Line


def line_base() -> Line:
    c = (
        Line()
        .add_xaxis((['2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015',
       '2016', '2017']))
        .add_yaxis("美", 美国)
        .add_yaxis("欧", 欧洲)
        .set_global_opts(title_opts=opts.TitleOpts(title="二氧化碳排放量"))
    )
    return c
In [55]:
e = line_base()
e.render_notebook()
Out[55]:
In [30]:
 
In [ ]: