当前位置: 首页>>代码示例>>Python>>正文


Python BarChart.series方法代码示例

本文整理汇总了Python中openpyxl.chart.BarChart.series方法的典型用法代码示例。如果您正苦于以下问题:Python BarChart.series方法的具体用法?Python BarChart.series怎么用?Python BarChart.series使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openpyxl.chart.BarChart的用法示例。


在下文中一共展示了BarChart.series方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ronava_bar_chart

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import series [as 别名]
def ronava_bar_chart(writingSheet, dataSheet, params):
    # TODO add dictionary in parameters to avoid overlapping
    if params["use"] == "bars":
        data = Reference(
            dataSheet,
            min_col=params["data_min_col"],
            min_row=params["data_min_row"],
            max_row=params["data_max_row"],
            max_col=params["data_max_col"],
        )
        cats = Reference(
            dataSheet,
            min_col=params["cats_min_col"],
            min_row=params["cats_min_row"],
            max_row=params["cats_max_row"],
            max_col=params["cats_max_col"],
        )
        chart = BarChart()
        chart.type = params["type"]
        chart.style = 12
        # chart.grouping = "stacked"
        chart.title = params["title"]
        chart.y_axis.title = params["y_axis"]
        chart.x_axis.title = params["x_axis"]
        chart.add_data(data, titles_from_data=True)
        chart.set_categories(cats)
        chart.height = params["heigth"]
        chart.width = params["width"]
        writingSheet.add_chart(chart, "D2")
    elif params["use"] == "single":
        c1 = BarChart()
        v1 = Reference(
            dataSheet, min_col=params["data_min_col"], min_row=params["data_min_row"], max_col=params["data_max_col"]
        )

        cats = Reference(
            dataSheet, min_col=params["cats_min_col"], min_row=params["cats_min_row"], max_col=params["cats_max_col"]
        )
        c1.series = [Series(v1, title_from_data=True)]
        c1.style = 12
        c1.set_categories(cats)
        c1.x_axis.title = params["x_axis"]
        c1.y_axis.title = params["y_axis"]
        c1.height = params["heigth"]
        c1.width = params["width"]
        c1.title = params["title"]
        writingSheet.add_chart(c1, "D4")
    else:
        c1 = BarChart()
        v1 = Reference(
            dataSheet, min_col=params["data_min_col"], min_row=params["data_min_row"], max_col=params["data_max_col"]
        )

        cats = Reference(
            dataSheet, min_col=params["cats_min_col"], min_row=params["cats_min_row"], max_col=params["cats_max_col"]
        )
        c1.series = [Series(v1, title_from_data=True)]
        c1.y_axis.majorGridlines = None
        c1.set_categories(cats)
        c1.x_axis.title = params["x_axis"]
        c1.y_axis.title = params["y_axis"]
        c1.height = params["heigth"]
        c1.width = params["width"]
        c1.title = params["title"]
        c1.style = 12
        # Create a second chart
        c2 = LineChart()
        v2 = Reference(
            dataSheet,
            min_col=params["data_min_col"],
            min_row=params["data_min_row"] + 1,
            max_col=params["data_max_col"],
        )
        c2.series = [Series(v2, title_from_data=True)]
        c2.y_axis.axId = 20
        c2.y_axis.title = "Porcentaje Produccion"
        # Assign the y-axis of the second chart to the third axis of the first chart
        c1.z_axis = c2.y_axis
        c1.y_axis.crosses = "max"
        c1 += c2

        writingSheet.add_chart(c1, "D4")
开发者ID:belgrades,项目名称:Ronava,代码行数:84,代码来源:ronava.py

示例2: Workbook

# 需要导入模块: from openpyxl.chart import BarChart [as 别名]
# 或者: from openpyxl.chart.BarChart import series [as 别名]
)

wb = Workbook()
ws = wb.active

rows = [
    ['Aliens', 2, 3, 4, 5, 6, 7],
    ['Humans', 10, 40, 50, 20, 10, 50],
]

for row in rows:
    ws.append(row)

c1 = BarChart()
v1 = Reference(ws, min_col=1, min_row=1, max_col=7)
c1.series = [Series(v1, title_from_data=True)]

c1.x_axis.title = 'Days'
c1.y_axis.title = 'Aliens'
c1.y_axis.majorGridlines = None
c1.title = 'Survey results'


# Create a second chart
c2 = LineChart()
v2 = Reference(ws, min_col=1, min_row=2, max_col=7)
c2.series = [Series(v2, title_from_data=True)]
c2.y_axis.axId = 20
c2.y_axis.title = "Humans"
# Assign the y-axis of the second chart to the third axis of the first chart
c1.z_axis = c2.y_axis
开发者ID:BespokeInsights,项目名称:openpyxl,代码行数:33,代码来源:secondary.py


注:本文中的openpyxl.chart.BarChart.series方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。