import
openpyxl
from
openpyxl.chart
import
ScatterChart, Reference, Series
wb
=
openpyxl.Workbook()
sheet
=
wb.active
rows
=
[
("Number of Products", "Sales
in
USD", "Market share"),
(
14
,
12200
,
15
),
(
20
,
60000
,
33
),
(
18
,
24400
,
10
),
(
22
,
32000
,
42
),
]
for
row
in
rows:
sheet.append(row)
chart
=
ScatterChart()
xvalues
=
Reference(sheet, min_col
=
1
,
min_row
=
2
, max_row
=
5
)
yvalues
=
Reference(sheet, min_col
=
2
,
min_row
=
2
, max_row
=
5
)
size
=
Reference(sheet, min_col
=
3
,
min_row
=
2
, max_row
=
5
)
series
=
Series(values
=
yvalues, xvalues
=
xvalues,
zvalues
=
size, title
=
"
2013
")
chart.series.append(series)
chart.title
=
" SCATTER
-
CHART "
chart.x_axis.title
=
" X_AXIS "
chart.y_axis.title
=
" Y_AXIS "
sheet.add_chart(chart, "E2")
wb.save(" ScatterChart.xlsx")