Python Forum
How to change font size of chart title and axis title ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change font size of chart title and axis title ?
#1
Hi, experts

I want to change font size of chart title and axis(x,y) title.
Can you help me ?

Thanks in advance

######################### BOF #######################################
### Python 3.6.3/ openpyxl 2.4.9
from datetime import date
from openpyxl import Workbook
from openpyxl.chart import (
LineChart,
Reference,
)
from openpyxl.chart.axis import DateAxis

wb = Workbook()
ws = wb.active

rows = [
['Date', 'Batch 1', 'Batch 2', 'Batch 3'],
[date(2015,9, 1), 40, 30, 25],
[date(2015,9, 2), 40, 25, 30],
[date(2015,9, 3), 50, 30, 45],
[date(2015,9, 4), 30, 25, 40],
[date(2015,9, 5), 25, 35, 30],
[date(2015,9, 6), 20, 40, 35],
]

for row in rows:
ws.append(row)

c1 = LineChart()
c1.title = "Line Chart"
c1.style = 13
c1.y_axis.title = 'Size'
c1.x_axis.title = 'Test Number'

data = Reference(ws, min_col=2, min_row=1, max_col=4, max_row=7)
c1.add_data(data, titles_from_data=True)

# Style the lines
s1 = c1.series[0]
s1.marker.symbol = "triangle"
s1.marker.graphicalProperties.solidFill = "FF0000" # Marker filling
s1.marker.graphicalProperties.line.solidFill = "FF0000" # Marker outline

s1.graphicalProperties.line.noFill = True

s2 = c1.series[1]
s2.graphicalProperties.line.solidFill = "00AAAA"
s2.graphicalProperties.line.dashStyle = "sysDot"
s2.graphicalProperties.line.width = 100050 # width in EMUs

s2 = c1.series[2]
s2.smooth = True # Make the line smooth
ws.add_chart(c1, "A10")
wb.save("line.xlsx")
Reply


Messages In This Thread
How to change font size of chart title and axis title ? - by thrupass - Nov-09-2017, 04:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I write formatted (i.e. bold, italic, change font size, etc.) text to a file? JohnJSal 13 29,066 May-20-2025, 12:26 PM
Last Post: hanmen9527
Question [split] How to ask Smart Questions (thread title expansion) darkuser 4 1,705 Nov-11-2024, 01:27 PM
Last Post: deanhystad
  IndexError: index 31 is out of bounds for axis 0 with size 31 YL789 1 1,042 Sep-21-2024, 09:46 AM
Last Post: Gribouillis
  Python code for alignment and font size 1418 0 1,034 Jan-14-2024, 03:56 AM
Last Post: 1418
  IndexError: index 10 is out of bounds for axis 0 with size 10 Mehboob 11 11,288 Sep-14-2023, 06:54 AM
Last Post: Mehboob
  read active document name - other than from the window title ineuw 0 1,034 Sep-11-2023, 09:06 AM
Last Post: ineuw
  Change font in a list or tuple apffal 4 3,908 Jun-16-2023, 02:55 AM
Last Post: schriftartenio
  Problem with scraping the Title from a web page Wagner822 0 1,334 Jun-29-2022, 11:31 PM
Last Post: Wagner822
  Change Text Size in Console? ShakeyPakey 9 15,880 Dec-09-2021, 02:51 AM
Last Post: drvlwho
  Sample labels from excel file in order to put them on x-axis and y-axis of a plot hobbyist 11 7,174 Sep-14-2021, 08:29 AM
Last Post: hobbyist

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020