You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a scatter chart, and am working to put Axis Titles on it. I have not been able to figure out how to do this. I think a tutorial showing this would be useful in the documentation. I have created an example, where I need help on the setAxisTitleText command. I appreciate your help
Thanks for the report, and for including your script. It shows the problem clearly.
With the current release (v0.13.4), setAxisTitleText needs the axis object rather than :x or :y. For a line chart:
xax =only(XLSX.Charts.getChartAxes(c, :category)) # the horizontal axis
yax =only(XLSX.Charts.getChartAxes(c, :value)) # the vertical axis
XLSX.Charts.setAxisTitleText(c, xax, "X Label")
XLSX.Charts.setAxisTitleText(c, yax, "Y Value")
The getChartAxis(cn, 1) line didn't work for two reasons. cn should be c. And the number getChartAxis takes is Excel's internal axis ID (usually a large number like 500000001), not the axis's position.
In the next release your original code will work as you wrote it. Axes can be named by where they're drawn:
XLSX.Charts.setAxisTitleText(c, :x, "X Label")
XLSX.Charts.setAxisTitleText(c, :y, "Y Value")
You can also set the titles when you create the chart:
c = XLSX.Charts.addChart(sheet, :line; anchor ="G1:O25", title ="Chart Title",
xtitle ="X Label", ytitle ="Y Value")
:x and :y are the axes as Excel draws them, so on a horizontal :bar chart :y is the category axis. :x2 and :y2 are the secondary axes of a combo chart. Every function that takes an axis will accept these names, so setAxisTitleTextProp(c, :y, :size, 12) and setAxisMin(c, :y, 0) will work too.
Calling getChartAxis(c, 1) gives an error that explains the axis ID. The Creating charts and Formatting charts pages of the docs show how to set axis titles.
I will try to push this to Master soon and will update here when I do.
Thank you for your timely response. I really appreciate that.
I changed the addChart line to be c = XLSX.Charts.addChart(sheet, :line; anchor="G1:O25", title="Chart Title", xtitle="X Label", ytitle="Y Value")
and did not execute the getChartAxis or setAxisTitleText commands.
I notice that the font style for the x and y axis is different from the Chart Title and different from the Excel default. I expect I can change that but I think it would be more convenient if they were the Excel default font and size and boldness.
Thanks for testing this, and you're right. A new axis title had no formatting of its own, so Excel fell back to 18pt black text, or 10pt bold when the title was bound to a cell. The same thing happened when a chart title was retyped with setChartTitleText.
On the next push to master, new axis titles look the same as ones you add in Excel: 10pt grey in the body font, and the vertical axis's title turned to read upwards. Changing a title's text now keeps its formatting, so a size or colour set earlier with setChartTitleTextProp / setAxisTitleTextProp stays. Your original script needs no changes.
Activity
TimG1964 commentedon Nov 14, 2026
Thanks for the report, and for including your script. It shows the problem clearly.
With the current release (v0.13.4),
setAxisTitleTextneeds the axis object rather than:xor:y. For a line chart:The
getChartAxis(cn, 1)line didn't work for two reasons.cnshould bec. And the numbergetChartAxistakes is Excel's internal axis ID (usually a large number like500000001), not the axis's position.In the next release your original code will work as you wrote it. Axes can be named by where they're drawn:
You can also set the titles when you create the chart:
:xand:yare the axes as Excel draws them, so on a horizontal:barchart:yis the category axis.:x2and:y2are the secondary axes of a combo chart. Every function that takes an axis will accept these names, sosetAxisTitleTextProp(c, :y, :size, 12)andsetAxisMin(c, :y, 0)will work too.Calling
getChartAxis(c, 1)gives an error that explains the axis ID. The Creating charts and Formatting charts pages of the docs show how to set axis titles.I will try to push this to Master soon and will update here when I do.
Fix issue #502 and speed up reading further.
TimG1964 commentedon Nov 15, 2026
This is now on Master if you want to try. There is a brief note on using
xtitleandytitlein the docs, too, which I hope is sufficient.JakeZw commentedon Nov 18, 2026
Thank you for your timely response. I really appreciate that.
I changed the addChart line to be
c = XLSX.Charts.addChart(sheet, :line; anchor="G1:O25", title="Chart Title", xtitle="X Label", ytitle="Y Value")and did not execute the
getChartAxisorsetAxisTitleTextcommands.I notice that the font style for the x and y axis is different from the Chart Title and different from the Excel default. I expect I can change that but I think it would be more convenient if they were the Excel default font and size and boldness.
JakeZw commentedon Nov 18, 2026
Another quick test using
c = XLSX.Charts.addChart(sheet, :line; anchor="G1:O25", title="Chart Title") XLSX.Charts.addSeries(c, "B2:B$(nr+1)", categories="A2:A$(nr+1)", name=column_labels[2]) XLSX.Charts.addSeries(c, "C2:C$(nr+1)", categories="A2:A$(nr+1)", name=column_labels[3]) XLSX.Charts.addSeries(c, "D2:D$(nr+1)", categories="A2:A$(nr+1)", name=column_labels[4]) XLSX.Charts.addSeries(c, "E2:E$(nr+1)", categories="A2:A$(nr+1)", name=column_labels[5]) XLSX.Charts.setAxisTitleText(c, :x, "X Label") XLSX.Charts.setAxisTitleText(c, :y, "Y Value")shows the same behaviour.
Sorry this shows poorly in Preview mode, it is fine in Write mode.
TimG1964 commentedon Nov 18, 2026
Thanks for testing this, and you're right. A new axis title had no formatting of its own, so Excel fell back to 18pt black text, or 10pt bold when the title was bound to a cell. The same thing happened when a chart title was retyped with setChartTitleText.
On the next push to master, new axis titles look the same as ones you add in Excel: 10pt grey in the body font, and the vertical axis's title turned to read upwards. Changing a title's text now keeps its formatting, so a size or colour set earlier with setChartTitleTextProp / setAxisTitleTextProp stays. Your original script needs no changes.
I'll update here when it's on master.
Further fix on Chart Axes for #502
Further fix on Chart Axes for #502
TimG1964 commentedon Nov 18, 2026
Should be on Master now.
JakeZw commentedon Nov 18, 2026
It is working well, thank you for your work.