def test_parallel_user_define(): c_schema = [ {"dim": 0, "name": "data"}, {"dim": 1, "name": "AQI"}, {"dim": 2, "name": "PM2.5"}, {"dim": 3, "name": "PM10"}, {"dim": 4, "name": "CO"}, {"dim": 5, "name": "NO2"}, {"dim": 6, "name": "CO2"}, {"dim": 7, "name": "等级", "type": "category", "data": ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']} ] data = [ [1, 91, 45, 125, 0.82, 34, 23, "良"], [2, 65, 27, 78, 0.86, 45, 29, "良"], [3, 83, 60, 84, 1.09, 73, 27, "良"], [4, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [5, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [6, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [7, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [8, 89, 65, 78, 0.86, 51, 26, "良"], [9, 53, 33, 47, 0.64, 50, 17, "良"], [10, 80, 55, 80, 1.01, 75, 24, "良"], [11, 117, 81, 124, 1.03, 45, 24, "轻度污染"], [12, 99, 71, 142, 1.1, 62, 42, "良"], [13, 95, 69, 130, 1.28, 74, 50, "良"], [14, 116, 87, 131, 1.47, 84, 40, "轻度污染"] ] parallel = Parallel("平行坐标系-用户自定义指示器") parallel.config(c_schema=c_schema) parallel.add("parallel", data) parallel.render()
def test_parallel_line_style(): schema = ["data", "AQI", "PM2.5", "PM10", "CO", "NO2"] data = [[1, 91, 45, 125, 0.82, 34]] parallel = Parallel() parallel.config(schema) parallel.add("parallel", data, line_width=20, line_opacity=0.5) html_content = parallel._repr_html_() assert '"width": 20' in html_content assert '"opacity": 0.5' in html_content
def test_parallel_user_define(): c_schema = [ { "dim": 0, "name": "data" }, { "dim": 1, "name": "AQI" }, { "dim": 2, "name": "PM2.5" }, { "dim": 3, "name": "PM10" }, { "dim": 4, "name": "CO" }, { "dim": 5, "name": "NO2" }, { "dim": 6, "name": "CO2" }, { "dim": 7, "name": "等级", "type": "category", "data": ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染'], }, ] data = [ [1, 91, 45, 125, 0.82, 34, 23, "良"], [2, 65, 27, 78, 0.86, 45, 29, "良"], [3, 83, 60, 84, 1.09, 73, 27, "良"], [4, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [5, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [6, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [7, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [8, 89, 65, 78, 0.86, 51, 26, "良"], [9, 53, 33, 47, 0.64, 50, 17, "良"], [10, 80, 55, 80, 1.01, 75, 24, "良"], [11, 117, 81, 124, 1.03, 45, 24, "轻度污染"], [12, 99, 71, 142, 1.1, 62, 42, "良"], [13, 95, 69, 130, 1.28, 74, 50, "良"], [14, 116, 87, 131, 1.47, 84, 40, "轻度污染"], ] parallel = Parallel("平行坐标系-用户自定义指示器") parallel.config(c_schema=c_schema) parallel.add("parallel", data) parallel.render()
def test_parallel_default(): schema = ["data", "AQI", "PM2.5", "PM10", "CO", "NO2"] data = [[1, 91, 45, 125, 0.82, 34], [ 2, 65, 27, 78, 0.86, 45, ], [3, 83, 60, 84, 1.09, 73], [4, 109, 81, 121, 1.28, 68], [5, 106, 77, 114, 1.07, 55], [6, 109, 81, 121, 1.28, 68], [7, 106, 77, 114, 1.07, 55], [8, 89, 65, 78, 0.86, 51, 26], [9, 53, 33, 47, 0.64, 50, 17], [10, 80, 55, 80, 1.01, 75, 24], [11, 117, 81, 124, 1.03, 45]] parallel = Parallel("平行坐标系-默认指示器") parallel.config(schema) parallel.add("parallel", data, is_random=True) parallel.render()
def test_parallel_default(): schema = ["data", "AQI", "PM2.5", "PM10", "CO", "NO2"] data = [ [1, 91, 45, 125, 0.82, 34], [2, 65, 27, 78, 0.86, 45, ], [3, 83, 60, 84, 1.09, 73], [4, 109, 81, 121, 1.28, 68], [5, 106, 77, 114, 1.07, 55], [6, 109, 81, 121, 1.28, 68], [7, 106, 77, 114, 1.07, 55], [8, 89, 65, 78, 0.86, 51, 26], [9, 53, 33, 47, 0.64, 50, 17], [10, 80, 55, 80, 1.01, 75, 24], [11, 117, 81, 124, 1.03, 45] ] parallel = Parallel("平行坐标系-默认指示器") parallel.config(schema) parallel.add("parallel", data, is_random=True) parallel.render()
[2, 65, 27, 78, 0.86, 45, 29, "良"], [3, 83, 60, 84, 1.09, 73, 27, "良"], [4, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [5, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [6, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [7, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [8, 89, 65, 78, 0.86, 51, 26, "良"], [9, 53, 33, 47, 0.64, 50, 17, "良"], [10, 80, 55, 80, 1.01, 75, 24, "良"], [11, 117, 81, 124, 1.03, 45, 24, "轻度污染"], [12, 99, 71, 142, 1.1, 62, 42, "良"], [13, 95, 69, 130, 1.28, 74, 50, "良"], [14, 116, 87, 131, 1.47, 84, 40, "轻度污染"] ] parallel = Parallel("平行坐标系-用户自定义指示器") parallel.config(c_schema=c_schema) parallel.add("parallel", data, is_random=False) parallel.render() # ----------------------------------------------------------------------------- # polar from pyecharts import Polar from pyecharts import Page page = Page() import random data = [(i, random.randint(1, 100)) for i in range(101)] #[(radius, angle)] polar = Polar("极坐标系") polar.add("", data, is_random=False) page.add(polar)
def create_charts(): page = Page() style = Style(width=WIDTH, height=HEIGHT) schema = ["data", "AQI", "PM2.5", "PM10", "CO", "NO2"] data = [[1, 91, 45, 125, 0.82, 34], [ 2, 65, 27, 78, 0.86, 45, ], [3, 83, 60, 84, 1.09, 73], [4, 109, 81, 121, 1.28, 68], [5, 106, 77, 114, 1.07, 55], [6, 109, 81, 121, 1.28, 68], [7, 106, 77, 114, 1.07, 55], [8, 89, 65, 78, 0.86, 51, 26], [9, 53, 33, 47, 0.64, 50, 17], [10, 80, 55, 80, 1.01, 75, 24], [11, 117, 81, 124, 1.03, 45]] chart = Parallel("平行坐标系-默认指示器", **style.init_style) chart.config(schema) chart.add("parallel", data, is_random=True) page.add(chart) c_schema = [{ "dim": 0, "name": "data" }, { "dim": 1, "name": "AQI" }, { "dim": 2, "name": "PM2.5" }, { "dim": 3, "name": "PM10" }, { "dim": 4, "name": "CO" }, { "dim": 5, "name": "NO2" }, { "dim": 6, "name": "CO2" }, { "dim": 7, "name": "等级", "type": "category", "data": ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染'] }] data = [[1, 91, 45, 125, 0.82, 34, 23, "良"], [2, 65, 27, 78, 0.86, 45, 29, "良"], [3, 83, 60, 84, 1.09, 73, 27, "良"], [4, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [5, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [6, 109, 81, 121, 1.28, 68, 51, "轻度污染"], [7, 106, 77, 114, 1.07, 55, 51, "轻度污染"], [8, 89, 65, 78, 0.86, 51, 26, "良"], [9, 53, 33, 47, 0.64, 50, 17, "良"], [10, 80, 55, 80, 1.01, 75, 24, "良"], [11, 117, 81, 124, 1.03, 45, 24, "轻度污染"], [12, 99, 71, 142, 1.1, 62, 42, "良"], [13, 95, 69, 130, 1.28, 74, 50, "良"], [14, 116, 87, 131, 1.47, 84, 40, "轻度污染"]] chart = Parallel("平行坐标系-用户自定义指示器", **style.init_style) chart.config(c_schema=c_schema) chart.add("parallel", data) page.add(chart) return page
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> # Part 11 Create Parallel Coordinate with Pyecharts >>> from pyecharts import Parallel >>> c_schema=[ {"dim": 0, "name": "data"}, {"dim": 1, "name": "AQI"}, {"dim": 2, "name": "PM2.5"}, {"dim": 3, "name": "PM10"}, {"dim": 4, "name": "CO"}, {"dim": 5, "name": "NO2"}, {"dim": 6, "name": "CO2"}, {"dim": 7, "name": "level", "type": "category", "data": ['Great', 'Good', 'MildPollution', 'Medium', 'Heavy', 'TerriblePollution']}] >>> data = [ [1, 91, 45, 125, 0.82, 34, 23, "Good"],[2, 65, 27, 78, 0.86, 45, 29, "Good"],[3, 83, 60, 84, 1.09, 73, 27, "Good"], [4, 109, 81, 121, 1.28, 68, 51, "MildPollution"], [5, 106, 77, 114, 1.07, 55, 51, "MildPollution"], [6, 109, 81, 121, 1.28, 68, 51, "MildPollution"], [7, 106, 77, 114, 1.07, 55, 51, "MildPollution"], [8, 89, 65, 78, 0.86, 51, 26, "Good"], [9, 53, 33, 47, 0.64, 50, 17, "Good"], [10, 80, 55, 80, 1.01, 75, 24, "Good"], [11, 117, 81, 124, 1.03, 45, 24, "MildPollution"], [12, 99, 71, 142, 1.1, 62, 42, "Good"], [13, 95, 69, 130, 1.28, 74, 50, "Good"], [14, 116, 87, 131, 1.47, 84, 40, "MildPollution"]] >>> parallel=Parallel("ParallelCoordinate-AirQulity Analysis") >>> parallel.config(c_schema = c_schema) <pyecharts.charts.parallel.Parallel object at 0x036619F0> >>> parallel.add("parallel",data) <pyecharts.charts.parallel.Parallel object at 0x036619F0> >>> parallel.render() >>>
from pyecharts import Parallel schema = ["data", "AQI", "PM2.5", "PM10", "CO", "NO2"] data = [[1, 91, 45, 125, 0.82, 34], [ 2, 65, 27, 78, 0.86, 45, ], [3, 83, 60, 84, 1.09, 73], [4, 109, 81, 121, 1.28, 68], [5, 106, 77, 114, 1.07, 55], [6, 109, 81, 121, 1.28, 68], [7, 106, 77, 114, 1.07, 55], [8, 89, 65, 78, 0.86, 51, 26], [9, 53, 33, 47, 0.64, 50, 17], [10, 80, 55, 80, 1.01, 75, 24], [11, 117, 81, 124, 1.03, 45]] parallel = Parallel("平行坐标系-默认") parallel.config(schema) parallel.add("parallel", data, is_more_utils=True) # parallel.add("parallel",data,is_more_utils=True,is_random=True) parallel.render(path="Parallel.html")