根据下面的图表,我正在寻找一种在XLSX-Writer中隐藏底部轴线而不丢失分类标签(6,7,8,9)的方法。
我已经尝试使用主网格线和次网格线,但没有任何效果(虽然这确实隐藏了刻度线,这是我的目标之一):
chart.set_x_axis({'major_tick_mark': 'none',
'minor_gridlines':{'visible':False}})提前感谢!

发布于 2018-02-08 01:46:32
可以使用line特性关闭轴线。您还需要关闭水平网格线。
这里有一个例子,我认为它复制了你正在寻找的东西:
import xlsxwriter
workbook = xlsxwriter.Workbook('chart.xlsx')
worksheet = workbook.add_worksheet()
# Create a new Chart object.
chart = workbook.add_chart({'type': 'column'})
# Write some data to add to plot on the chart.
worksheet.write_column('A1', [6, 7, 8, 9])
worksheet.write_column('B1', [50, 70, 60, 80])
# Configure the charts. In simplest case we just add some data series.
chart.add_series({'categories': '=Sheet1!$A$1:$A$4',
'values': '=Sheet1!$B$1:$B$4'})
# Turn off the X axis line.
chart.set_x_axis({'line': {'none': True}})
# Turn off the Y axis and horizontal gridlines.
chart.set_y_axis({'visible': False,
'major_gridlines': {'visible': False}})
# Turn off the chart legend.
chart.set_legend({'none': True})
# Insert the chart into the worksheet.
worksheet.insert_chart('B7', chart)
workbook.close()输出:

https://stackoverflow.com/questions/48668199
复制相似问题