Python notes: making various water polo diagrams

In this paper, pyechart v1. X is used to draw the water polo map.

Note: PyEcharts is divided into two major versions: v0.5.x and v1.x. they are incompatible. v0.5.x is developed based on Python 2.7 +, 3.4 +, and v1.x is a new version. It is developed based on Python 3.6 +, and the 0.5.x version will not be maintained by PyEcharts development team.

 

Premise:

# Install the pyecharts module. Direct installation is the latest version
pip install pyecharts
#Guide bag
from pyecharts import options as opts
from pyecharts.charts import Liquid

The data of water polo chart is very simple, which is a completion rate number, so there is no need to define or import, and no need to transform.

Next, you can draw the water polo map:

from pyecharts import options as opts
from pyecharts.charts import Liquid

c = (
    #Create a water polo object
     Liquid()
     #Set data series name and data, is_outline_show is to set the border line according to your preference
    .add("Achievement rate", [0.66], is_outline_show = False)
     # Set chart title and location
    .set_global_opts(title_opts = opts.TitleOpts(title = "Sales achievement rate of vegetable sector",pos_left = "center"))
     #Render the water polo map as html by the render() method
#     . render("round water polo. html")
)
c.render_notebook()

The color of the water polo chart can be set. You only need to add the color parameter in add(). The code is as follows:

from pyecharts import options as opts
from pyecharts.charts import Liquid

c = (
    Liquid()
    .add("Achievement rate", [0.88], is_outline_show = False, color = ['#DC143C'])
    .set_global_opts(title_opts = opts.TitleOpts(title = "Sales achievement rate of fruit Department",pos_left = "center"))
#     . render("round water polo. html")
)
c.render_notebook()

Red water polo:

The shape of the water polo can also be customized:

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
    Liquid()
    .add("Achievement rate", [0.777], is_outline_show = False, shape = SymbolType.RECT)
    .set_global_opts(title_opts = opts.TitleOpts(title = "Achievement rate of aquatic product sales",pos_left = "center"))
#     . render("rectangular water polo. html")
)
c.render_notebook()

Rectangular water polo:

 

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
    Liquid()
    .add("Achievement rate", [0.90], is_outline_show = False, shape = SymbolType.DIAMOND)
    .set_global_opts(title_opts = opts.TitleOpts(title = "Sales achievement rate of Comprehensive Department",pos_left = "center"))
#     . render("rectangular water polo. html")
)
c.render_notebook()

See the difference? Just add shape in add()= SymbolType.RECT At the same time, you need to import the corresponding module: from pyecharts.globals import SymbolType

In addition, shape=SymbolType.DIAMOND Diamond water polo

 

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
    Liquid()
    .add("Achievement rate", [0.60], is_outline_show = False, shape = SymbolType.ROUND_RECT)
    .set_global_opts(title_opts = opts.TitleOpts(title = "Sales achievement rate of e-commerce Department",pos_left = "center"))
#     . render("rectangular water polo. html")
)
c.render_notebook()

shape=SymbolType.ROUND_RECT is the rounded rectangle water polo

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
    Liquid()
    .add("Achievement rate", [0.67], is_outline_show = False, shape = SymbolType.TRIANGLE)
    .set_global_opts(title_opts = opts.TitleOpts(title = "Sales achievement rate of pork Department",pos_left = "center"))
#     . render("rectangular water polo. html")
)
c.render_notebook()

shape=SymbolType.TRIANGLE It's a triangle of water balls

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
    Liquid()
    .add("Achievement rate", [0.56], is_outline_show = False, shape = SymbolType.ARROW)
    .set_global_opts(title_opts = opts.TitleOpts(title = "Sales achievement rate of material department",pos_left = "center"))
#     . render("rectangular water polo. html")
)
c.render_notebook()

shape=SymbolType.ARROW It's the arrow water polo

Isn't it easy to make a water polo picture_ ?)

Tags: Python pip

Posted on Sat, 30 May 2020 10:23:02 -0400 by ec