系列配置项
使用set_series_opts设置系列配置项
图元样式配置项
from pyecharts.faker import Faker
from pyecharts.charts import Bar
from pyecharts import options as opts
def bar_item():
bar = Bar()
bar.add_xaxis(Faker.choose())
bar.add_yaxis("图元系列配置项", Faker.values())
bar.set_series_opts(
itemstyle_opts=opts.ItemStyleOpts(
border_width=3, #描边宽度
border_color="black", #图形的描边颜色
color="gray"#图形的颜色
)
)
return bar
bar_item().render_notebook()
标签配置项
from pyecharts.faker import Faker
from pyecharts.charts import Bar
from pyecharts import options as opts
def bar_label():
bar = Bar()
bar.add_xaxis(Faker.choose())
bar.add_yaxis("标签配置项", Faker.values())
bar.set_series_opts(
label_opts=opts.LabelOpts(
is_show = True,#是否展示标签
font_size = 30,#字体大小
font_style = "italic",#字体风格
font_weight = "bolder",#字体粗细
horizontal_align = "right"#字体的水平对齐方式
)
)
return bar
bar_label().render_notebook()
线样式配置项
from pyecharts.faker import Faker
from pyecharts.charts import Line
from pyecharts import options as opts
def line_style():
line = Line()
line.add_xaxis(Faker.choose())
line.add_yaxis("线样式配置项", Faker.values())
line.set_series_opts(
linestyle_opts=opts.LineStyleOpts(
is_show = True,#是否显示
width = 5,#线宽
opacity = 0.5,#图形透明度为 0 时不绘制该图形
curve = 0,# 线的弯曲度,0 表示完全不弯曲
type_ = "dashed",#线的类型
color = "#000000"#线的颜色
)
)
return line
line_style().render_notebook()
3D线样式配置项
from pyecharts import options as opts
from pyecharts.charts import Map3D
from pyecharts.globals import ChartType
example_data = [[[120.237536, 35.965021, 1000], [120.426108, 36.081083, 1000]]]#列表中前两个值为地区的经纬度
def map3d():
c = (
Map3D()#3D地图
.add_schema(
maptype="青岛",
itemstyle_opts=opts.ItemStyleOpts(#图元样式配置项
color="#C0C0C0",
border_width=0.8,
border_color="black",
)
)
.add(
series_name="3D线样式配置项",
data_pair=example_data,#给3D地图添加数据
type_=ChartType.LINES3D,#设置叠加图的类型
effect=opts.Lines3DEffectOpts(#飞线的尾迹特效仅在Line3D中有用,即3D线样式配置项
is_show=True,#是否显示
period=4,#尾迹特效的周期
trail_width=10,#尾迹的宽度
trail_length=0.5,#尾迹的长度(取值从0到1)
trail_color="blue",#尾迹的颜色
trail_opacity=1,#尾迹的不透明度(取值从0到1)
)
)
.set_global_opts(visualmap_opts=opts.VisualMapOpts(is_show=False))
)
return c
map3d().render_notebook()
标记点、标记线配置项
from pyecharts.faker import Faker
from pyecharts.charts import Bar
from pyecharts import options as opts
def bar_mark():
bar = Bar()
bar.add_xaxis(Faker.choose())
bar.add_yaxis("标记点、标记线配置项", Faker.values())
bar.set_series_opts(
label_opts = opts.LabelOpts(is_show = False),#不显示标签配置项
markpoint_opts = opts.MarkPointOpts(#设置标记点配置项
data=[
opts.MarkPointItem(type_ = "max", name = "最大值"),#添加标记点数据项
opts.MarkPointItem(type_ = "min", name = "最小值")],
label_opts = opts.LabelOpts(position = "inside",color = "black")#设置标记点的标签
),
markline_opts = opts.MarkLineOpts(#设置标记线配置项
data=[
opts.MarkLineItem(type_ = "max", name = "最大值"),#添加标记线数据项
opts.MarkLineItem(type_ = "min", name = "最小值")],
label_opts = opts.LabelOpts(position = "inside",color = "black")#设置标记线的标签
)
)
return bar
bar_mark().render_notebook()