根据下面的图表,我在XLSX-Writer中寻找隐藏底部轴线而不会丢失分类标签的方法([6,7,8,9])。
我尝试使用主要和次要网格线,但没有骰子(虽然这确实隐藏了刻度线,这是我的目标之一):
chart.set_x_axis({'major_tick_mark': 'none',
'minor_gridlines':{'visible':False}})
提前致谢!
答案 0 :(得分:2)
您可以使用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()
输出: