openpyxlを使って散布図を作成しているのですが,目盛り線の削除方法が分かりません
pthon
1chart.x_axis.majorGridLines = None 2chart.y_axis.majorGridLines = None
で削除できると思うのですが,うまくいきません.
こんな感じで書いてあります.
python
1import pandas as pd 2import openpyxl as px 3from openpyxl import Workbook 4from openpyxl.chart import (ScatterChart,Reference,Series,) 5from openpyxl.utils.dataframe import dataframe_to_rows 6from openpyxl.chart.shapes import GraphicalProperties 7from openpyxl.drawing.line import LineProperties 8 9 10 11files = ["D:\CMCS1.csv", 12 "D:\CMCS2.csv", 13 "D:\CMCS3.csv", 14 "D:\CMCS4.csv",] 15 16def Extraction(file): 17 df = pd.read_csv(file,skiprows=1) 18 df = df.dropna() 19 df = df["%T"] 20 return df 21 22ys = pd.DataFrame() 23file_names = [] 24for file in files: 25 y = Extraction(file) 26 ys = pd.concat([ys, y], axis=1) 27 file_names.append(file.split('.', 1)[0]) 28ys.columns = file_names 29x = pd.DataFrame(range(4000,449,-1), columns=["cm-1"]) 30df = pd.concat([x, ys], axis=1) 31 32 33df.to_excel('D:\sample.xlsx', sheet_name='IRスペクトル', index = False) 34 35 36wb = px.load_workbook('D:\python\sample.xlsx') 37 38chart = px.chart.ScatterChart() 39chart.style = 13 40chart.width = 15 41chart.height = 10 42chart.title = None 43 44chart.x_axis.scaling.max = 4000 45chart.x_axis.majorTickMark = "in" 46chart.x_axis.minorTickMark = "in" 47chart.x_axis.majorUnit = 500 48chart.x_axis.minorUnitt = 100 49chart.x_axis.scaling.min = 500 50chart.x_axis.scaling.orientation = "maxMin" 51chart.x_axis.title = 'Wave Number / cm-1' 52#問題の部分↓ 53chart.x_axis.majorGridLines = None 54chart.x_axis.spPr = GraphicalProperties(ln =LineProperties(solidFill="000000", w=1*12700)) 55 56chart.y_axis.title = 'Percentage' 57chart.y_axis.title = None 58chart.y_axis.delete = True 59#問題の部分↓ 60chart.y_axis.majorGridLines = None 61 62chart.legend = None 63chart.plot_area.spPr = GraphicalProperties(ln = LineProperties(solidFill = "000000", w=1*12700)) 64 65x = px.chart.Reference(wb['IRスペクトル'] ,min_col=1 ,min_row=2 ,max_row=3552) 66 67for i in range(2, 6): 68 y = px.chart.Reference(wb['IRスペクトル'] ,min_col=i ,min_row=1 ,max_row=3552) 69 series = px.chart.Series(y, x,title_from_data=True) 70 chart.series.append(series) 71 series.spPr.ln.solidFill = "000000" 72 series.spPr.ln.w = 1 * 12700 73 74wb['IRスペクトル'].add_chart(chart,"A6") 75 76wb.save("D:\sample.xlsx")
あなたの回答
tips
プレビュー