如何在python openpyxl中从左到右交换组合图表的y轴?

How to swap the y axis of a combination chart from left to right in python openpyxl?

如何更改组合图表上的 y 轴刻度? 我有一个带有第二个折线图的 Stacked Bar。我希望堆叠条形 y 轴位于左侧,第二个折线图的刻度位于右侧。所以这将是两个 y 轴的交换。

这是我的图表:

    chart1 = BarChart()
chart1.type = "col"
chart1.style = 12
chart1.grouping = "stacked"
chart1.overlap = 100

chart1.layout = Layout(
    ManualLayout(
    x=0.12, y=0.25, 
    h=0.9, w=0.75, 
    xMode="edge",
    yMode="edge",
    )
)

...

chart2 = LineChart()
chart2.style = 12
chart2.y_axis.axId = 0

...

    chart1.y_axis.crosses = "max"
chart1 += chart2
    WorkSheetOne.add_chart(chart1, 'A1')

Resolved in comments:

Best bet is to change the order of the charts.  
The logic for this is hard-coded in the library and difficult to change due to the XML. – Charlie Clark

我尝试更改顺序:

chart1.y_axis.crosses = "max" 
chart2 += chart1 
WorkSheetOne.add_chart(chart2, 'A1') 

但这并没有奏效,直到我也改变了:

chart2.y_axis.crosses = "max" 

而且我还必须更改:chart2.title 因为 chart1.title 现在被忽略了。

对于具有单个数据系列的条形图,我可以通过以下方式颠倒顺序:

    chart.x_axis.scaling.orientation = "maxMin"
    chart.y_axis.scaling.orientation = "minMax"