Home > other >  Openpyxl production Chart X Y upside down
Openpyxl production Chart X Y upside down

Time:09-18

Consult BBS inside the great god, and how to implement the following Chart with openpyxl?
I Excel in data is horizontally arranged, don't know how to Reference data in the Reference,


CodePudding user response:

I also encountered this problem, only the form first. T transposed, can use refrence, or data is quoted wrong, hope to have other solutions to bosses

CodePudding user response:

With reference to the official or I this
https://blog.csdn.net/weixin_45903952/article/details/105126839#comments_12157166

CodePudding user response:

@ weixin_45903952
With reference to your post, I do out is like this,
The from openpyxl import Workbook
The from openpyxl import load_workbook
The from openpyxl. Chart import BarChart Series, the Reference

Wb=load_workbook (' a55aa. XLSX)
Ws=wb. Get_sheet_by_name (" New Title ")


Chart1=BarChart ()
Chart1. Type="col"
Chart1. Style=10
Chart1. Title="Bar Chart"
Chart1. Y_axis. Title='Test number'
Chart1. X_axis. Title='Sample length (mm)'


Data=https://bbs.csdn.net/topics/Reference (ws, min_col=8, max_col=9, min_row=9)
Cats=Reference (ws, min_col=8, max_col=9, min_row=8, max_row=8)
Chart1. Add_data (data, titles_from_data=https://bbs.csdn.net/topics/True)
Chart1. Set_categories (cats)
Chart1. Shape=4


Ws. Add_chart (chart1, "A20")
Wb. Save (' a55aa. XLSX)


Have progress than before, the feeling is going to succeed,

CodePudding user response:

The
reference 3 floor Gordon_Chen response:
@ weixin_45903952
With reference to your post, I do out is like this,
The from openpyxl import Workbook
The from openpyxl import load_workbook
The from openpyxl. Chart import BarChart Series, the Reference

Wb=load_workbook (' a55aa. XLSX)
Ws=wb. Get_sheet_by_name (" New Title ")


Chart1=BarChart ()
Chart1. Type="col"
Chart1. Style=10
Chart1. Title="Bar Chart"
Chart1. Y_axis. Title='Test number'
Chart1. X_axis. Title='Sample length (mm)'


Data=https://bbs.csdn.net/topics/Reference (ws, min_col=8, max_col=9, min_row=9)
Cats=Reference (ws, min_col=8, max_col=9, min_row=8, max_row=8)
Chart1. Add_data (data, titles_from_data=https://bbs.csdn.net/topics/True)
Chart1. Set_categories (cats)
Chart1. Shape=4


Ws. Add_chart (chart1, "A20")
Wb. Save (' a55aa. XLSX)


Have progress than before, the feeling is going to succeed,


As reference data is wrong, is a set of data, 100150

CodePudding user response:

You transpose the data reference

CodePudding user response:

reference 5 floor weixin_45903952 reply:
you transpose the data refer to see


After I transposed is correct, but the actual report data is transversely, depressed

CodePudding user response:

refer to 6th floor Gordon_Chen response:
Quote: refer to the fifth floor weixin_45903952 reply:

You transpose the data refer to see


After I transposed is correct, but the actual report data is transversely, depressed


This is the place where I depressed, can't, only longitudinal data
  • Related