简体   繁体   中英

Openpyxl to move the position of bar chart within excel sheet

I am using Openpyxl to write several tabs/sheets to an excel file. Why I chose Openpyxl over xlswriter is because I would like to load an existing workbook and create a bar chart using specific columns and rows.

The problem is the bar chart is positioned by default over the data and I would like to position it either below the data or to the right side of data.

Are there parameters that we can use to move the position of the container which holds the bar chart.

We can do this in xlswriter using x_offset and y_offset parameters while inserting the chart. Is there similar functionality with openpyxl.

Any help would be appreciated.

You can position the chart in a cell. For example, the following chart would be inserted in cell B5. ws.add_chart(chart, "B5")

The top left of the chart is now anchored to B5. You can change the anchor parameter to another cell reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM