Home

Speaking of Excel and Python


According to the VB Object browser, the AxisGroup property of a series is read/write and it would appear that that is true. When I record a macro of me changing a series’ axis from primary to secondary I see something like

` series.AxisGroup = 2 `

However, if I try to perform the same action in Python I get an error along the lines of:

`
AttributeError: Property ‘NewSeries.AxisGroup’ can not be set.
`

I’m thinking it has something to do with the NewSeries part of this. There is an AxisGroup property of the Axis class that is Read-only but I don’t see how that could be coming into play here. More on this exciting development as information becomes available!

Solution:

-By default a two dimentional graph has two axes defined. You obviously can’t tell a series to be set to the secondary y-axis if one doesn’t exist! Therefore you have to explicitly setup your axes like so:-

This is obviously false because I can remove the third line here and still get my secondary axis. I think the issue lied more with that I hadn’t setup ANY axes and that I hadn’t provided any data yet.

 xAxis = chart.Axes()[0] yAxis1 = chart.Axes()[1]

Then you can happily assisn your series’ to the secondary axis with no problems!

If you want to set the properties of the secondary axis, you do it like this:

 chart.Axes(2,2).MinimumScale = 0 chart.Axes(2,2).MaximumScale = 0.05