【Method】
Use the **AxisBetweenCategories** property of the **Axis** object to set the intersection point between the value axis and the category axis. If the value is `True`, the intersection occurs in the middle of the categories; if it is `False`, the intersection occurs at the middle point of the categories.
The **Crosses** property of the **Axis** object returns or sets the point at which the axis intersects with another axis. The possible values for this property are as follows:
|
Name |
Value |
Description |
|
xlAxisCrossesAutomatic |
-4105 |
Automatically set by Excel |
|
xlAxisCrossesCustom |
-4114 |
Set by **CrossesAt** property |
|
xlAxisCrossesMaximum |
2 |
Axis crosses at maximum value |
|
xlAxisCrossesMinimum |
4 |
Axis crosses at minimum value |
sht.api.Range(‘A1:B7’).Select()
cht=sht.api.Shapes.AddChart().Chart
axs2=cht.Axes(2)
axs2.Crosses=2
#axs2.Crosses=-4114
#axs2.CrossesAt=50
【Example】

【Code】
import xlwings as xw
import os
root=os.getcwd()
app=xw.App(visible=True,add_book=False)
wb=app.books.open(root+r'/data2.xlsx',read_only=False)
sht=wb.sheets('Sheet1')
sht.api.Range('A1:B7').Select() #
shp=sht.api.Shapes.AddChart() #
shp.Left=20
cht=shp.Chart
axs=cht.Axes(1) #
axs.Border.ColorIndex=3 #
axs.Border.Weight=3 #
axs2=cht.Axes(2) #
axs.Crosses=xw.constants.AxisCrosses.xlAxisCrossesMaximum
axs2.CrossesAt=10
#wb.save()
#app.kill()

Leave a Reply