pitchPowerAnalyst.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. import os
  2. from datetime import datetime
  3. import numpy as np
  4. import pandas as pd
  5. import plotly.express as px
  6. import plotly.graph_objects as go
  7. from algorithmContract.confBusiness import *
  8. from algorithmContract.contract import Contract
  9. from behavior.analystWithGoodBadPoint import AnalystWithGoodBadPoint
  10. class PitchPowerAnalyst(AnalystWithGoodBadPoint):
  11. """
  12. 风电机组变桨-功率分析
  13. """
  14. def typeAnalyst(self):
  15. return "pitch_power"
  16. def selectColumns(self):
  17. return [Field_DeviceCode, Field_Time,Field_WindSpeed, Field_ActiverPower, Field_PitchAngel1]
  18. def turbinesAnalysis(self, outputAnalysisDir, conf: Contract, turbineCodes):
  19. dictionary = self.processTurbineData(turbineCodes, conf,self.selectColumns())
  20. dataFrame = self.userDataFrame(dictionary,conf.dataContract.configAnalysis,self)
  21. turbineInfos = self.common.getTurbineInfos(conf.dataContract.dataFilter.powerFarmID, turbineCodes,
  22. self.turbineInfo)
  23. result_df1 = self.plot_power_pitch_angle(dataFrame, turbineInfos, outputAnalysisDir, conf)
  24. result_df2 = self.drawScatterGraph(dataFrame, turbineInfos, outputAnalysisDir, conf)
  25. result_df = pd.concat([result_df1, result_df2], ignore_index=True)
  26. return result_df
  27. def plot_power_pitch_angle(self, dataFrame:pd.DataFrame, turbineModelInfo: pd.Series, outputAnalysisDir:str, conf: Contract):
  28. # 按设备名分组数据
  29. dataFrameMerge = dataFrame[(dataFrame[Field_ActiverPower] > 0)].sort_values(by=Field_YearMonth)
  30. grouped = dataFrameMerge.groupby([Field_NameOfTurbine, Field_CodeOfTurbine])
  31. # 定义固定的颜色映射列表
  32. fixed_colors = [
  33. "#3E409C",
  34. "#476CB9",
  35. "#3586BF",
  36. "#4FA4B5",
  37. "#52A3AE",
  38. "#60C5A3",
  39. "#85D0AE",
  40. "#A8DCA2",
  41. "#CFEE9E",
  42. "#E4F39E",
  43. "#EEF9A7",
  44. "#FBFFBE",
  45. "#FDF1A9",
  46. "#FFE286",
  47. "#FFC475",
  48. "#FCB06C",
  49. "#F78F4F",
  50. "#F96F4A",
  51. "#E4574C",
  52. "#CA3756",
  53. "#AF254F"
  54. ]
  55. # 将 fixed_colors 转换为 Plotly 的 colorscale 格式
  56. fixed_colorscale = [
  57. [i / (len(fixed_colors) - 1), color] for i, color in enumerate(fixed_colors)
  58. ]
  59. # 遍历每个设备并绘制散点图
  60. result_rows1 = []
  61. for name, group in grouped:
  62. # 创建图形
  63. fig = go.Figure()
  64. # 添加散点图
  65. fig.add_trace(go.Scatter(
  66. x=group[Field_ActiverPower],
  67. y=group[Field_PitchAngel1],
  68. mode='markers',
  69. # marker=dict(color='blue', size=3.5)
  70. marker=dict(
  71. color=group[Field_UnixYearMonth],
  72. colorscale=fixed_colorscale,
  73. size=3,
  74. opacity=0.7,
  75. colorbar=dict(
  76. tickvals=np.linspace(
  77. group[Field_UnixYearMonth].min(), group[Field_UnixYearMonth].max(), 6),
  78. ticktext=[datetime.fromtimestamp(ts).strftime('%Y-%m') for ts in np.linspace(
  79. group[Field_UnixYearMonth].min(), group[Field_UnixYearMonth].max(), 6)],
  80. thickness=18,
  81. len=1, # 设置颜色条的长度,使其占据整个图的高度
  82. outlinecolor='rgba(255,255,255,0)'
  83. ),
  84. showscale=True
  85. ),
  86. showlegend=False
  87. ))
  88. # 设置图形布局
  89. fig.update_layout(
  90. title=f'机组: {name[0]}',
  91. xaxis=dict(
  92. title='功率',
  93. range=[self.axisLowerLimitActivePower,
  94. self.axisUpperLimitActivePower],
  95. dtick=self.axisStepActivePower,
  96. tickangle=-45 # 设置x轴刻度值旋转角度为45度,如果需要
  97. ),
  98. yaxis=dict(
  99. title='桨距角',
  100. range=[self.axisLowerLimitPitchAngle,
  101. self.axisUpperLimitPitchAngle],
  102. dtick=self.axisStepPitchAngle
  103. ),
  104. coloraxis=dict(
  105. colorbar=dict(
  106. title="时间",
  107. ticks="outside",
  108. len=1, # 设置颜色条的长度,使其占据整个图的高度
  109. thickness=20, # 调整颜色条的宽度
  110. orientation='v', # 设置颜色条为垂直方向
  111. tickmode='array', # 确保刻度按顺序排列
  112. tickvals=dataFrameMerge[Field_YearMonth].unique(
  113. ).tolist(), # 确保刻度为唯一的年月
  114. ticktext=dataFrameMerge[Field_YearMonth].unique(
  115. ).tolist() # 以%Y-%m格式显示标签
  116. )
  117. )
  118. )
  119. # 确保从 Series 中提取的是具体的值
  120. engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
  121. if isinstance(engineTypeCode, pd.Series):
  122. engineTypeCode = engineTypeCode.iloc[0]
  123. engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
  124. if isinstance(engineTypeName, pd.Series):
  125. engineTypeName = engineTypeName.iloc[0]
  126. # 构建最终的JSON对象
  127. json_output = {
  128. "analysisTypeCode": "变桨和有功功率协调性分析",
  129. "engineCode": engineTypeCode,
  130. "engineTypeName": engineTypeName,
  131. "xaixs": "功率(kW)",
  132. "yaixs": "桨距角(°)",
  133. "data": [{
  134. "engineName": name[0],
  135. "engineCode": name[1],
  136. "title": f' 机组: {name[0]}',
  137. "xData": group[Field_ActiverPower].tolist(),
  138. "yData": group[Field_PitchAngel1].tolist(),
  139. "timeData": group[Field_UnixYearMonth].tolist(),
  140. # "colorbar": dataFrameMerge[Field_YearMonth].unique().tolist(),
  141. "colorbar": group[Field_YearMonth].tolist(),
  142. }]
  143. }
  144. # 保存图像
  145. # filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}.png")
  146. # fig.write_image(filePathOfImage, width=800, height=600, scale=3)
  147. # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}.html")
  148. # fig.write_html(filePathOfHtml)
  149. # 将JSON对象保存到文件
  150. output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}.json")
  151. with open(output_json_path, 'w', encoding='utf-8') as f:
  152. import json
  153. json.dump(json_output, f, ensure_ascii=False, indent=4)
  154. # result_rows1.append({
  155. # Field_Return_TypeAnalyst: self.typeAnalyst(),
  156. # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  157. # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  158. # Field_CodeOfTurbine: name[1],
  159. # Field_Return_FilePath: filePathOfImage,
  160. # Field_Return_IsSaveDatabase: False
  161. # })
  162. result_rows1.append({
  163. Field_Return_TypeAnalyst: self.typeAnalyst(),
  164. Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  165. Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  166. Field_CodeOfTurbine: name[1],
  167. Field_MillTypeCode: 'total',
  168. Field_Return_FilePath: output_json_path,
  169. Field_Return_IsSaveDatabase: True
  170. })
  171. result_df1 = pd.DataFrame(result_rows1)
  172. return result_df1
  173. def drawScatterGraph(self, dataFrame: pd.DataFrame, turbineModelInfo: pd.Series, outputAnalysisDir: str, conf: Contract):
  174. dataFrame = dataFrame[(dataFrame[Field_ActiverPower] > 0)].sort_values(
  175. by=Field_YearMonth)
  176. grouped = dataFrame.groupby([Field_NameOfTurbine, Field_CodeOfTurbine])
  177. '''
  178. # 遍历每个设备的数据
  179. result_rows2 = []
  180. for name, group in grouped:
  181. if len(group[Field_YearMonth].unique()) > 1:
  182. fig = px.scatter_3d(dataFrame,
  183. x=Field_PitchAngel1,
  184. y=Field_YearMonth,
  185. z=Field_ActiverPower,
  186. color=Field_YearMonth,
  187. labels={Field_PitchAngel1: '桨距角',
  188. Field_YearMonth: '时间', Field_ActiverPower: '功率'},
  189. )
  190. # 设置固定散点大小
  191. fig.update_traces(marker=dict(size=1.5))
  192. # 更新图形的布局
  193. fig.update_layout(
  194. title={
  195. "text": f'月度桨距角功率3D散点图: {name[0]}',
  196. "x": 0.5
  197. },
  198. scene=dict(
  199. xaxis=dict(
  200. title='桨距角',
  201. dtick=self.axisStepPitchAngle,
  202. range=[self.axisLowerLimitPitchAngle,
  203. self.axisUpperLimitPitchAngle],
  204. ),
  205. yaxis=dict(
  206. title='时间',
  207. tickformat='%Y-%m', # 日期格式,
  208. dtick='M1', # 每月一个刻度
  209. showgrid=True, # 显示网格线
  210. ),
  211. zaxis=dict(
  212. title='功率',
  213. dtick=self.axisStepActivePower,
  214. range=[self.axisLowerLimitActivePower,
  215. self.axisUpperLimitActivePower],
  216. showgrid=True, # 显示网格线
  217. )
  218. ),
  219. scene_camera=dict(
  220. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  221. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  222. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  223. ),
  224. # 设置图例标题
  225. # legend_title_text='Time',
  226. legend=dict(
  227. orientation="h",
  228. itemsizing="constant", # Use constant size for legend items
  229. itemwidth=80 # Set the width of legend items to 50 pixels
  230. )
  231. )
  232. '''
  233. # 假设 colorsList 已经在代码的其他部分定义
  234. colorsList = [
  235. "#3E409C",
  236. "#3586BF",
  237. "#52A3AE",
  238. "#85D0AE",
  239. "#A8DCA2",
  240. "#FBFFBE",
  241. "#FDF1A9",
  242. "#FFE286",
  243. "#FCB06C",
  244. "#F96F4A",
  245. "#E4574C",
  246. "#AF254F"
  247. ]
  248. # 遍历每个设备的数据
  249. result_rows2 = []
  250. for name, group in grouped:
  251. if len(group[Field_YearMonth].unique()) > 1:
  252. fig = px.scatter_3d(
  253. group,
  254. x=Field_PitchAngel1,
  255. y=Field_YearMonth,
  256. z=Field_ActiverPower,
  257. color=Field_YearMonth,
  258. color_discrete_sequence=colorsList, # 使用 colorsList 作为颜色映射
  259. labels={
  260. Field_PitchAngel1: '桨距角',
  261. Field_YearMonth: '时间',
  262. Field_ActiverPower: '功率'
  263. },
  264. )
  265. # 设置固定散点大小
  266. fig.update_traces(marker=dict(size=1.5))
  267. # 更新图形的布局
  268. fig.update_layout(
  269. title={
  270. "text": f'月度桨距角功率3D散点图: {name[0]}',
  271. "x": 0.5
  272. },
  273. scene=dict(
  274. xaxis=dict(
  275. title='桨距角',
  276. dtick=self.axisStepPitchAngle,
  277. range=[self.axisLowerLimitPitchAngle, self.axisUpperLimitPitchAngle],
  278. ),
  279. yaxis=dict(
  280. title='时间',
  281. tickformat='%Y-%m', # 日期格式,
  282. dtick='M1', # 每月一个刻度
  283. showgrid=True, # 显示网格线
  284. ),
  285. zaxis=dict(
  286. title='功率',
  287. dtick=self.axisStepActivePower,
  288. range=[self.axisLowerLimitActivePower, self.axisUpperLimitActivePower],
  289. showgrid=True, # 显示网格线
  290. )
  291. ),
  292. scene_camera=dict(
  293. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  294. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  295. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  296. ),
  297. legend=dict(
  298. orientation="h",
  299. itemsizing="constant", # Use constant size for legend items
  300. itemwidth=80 # Set the width of legend items to 50 pixels
  301. )
  302. )
  303. # 确保从 Series 中提取的是具体的值
  304. engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
  305. if isinstance(engineTypeCode, pd.Series):
  306. engineTypeCode = engineTypeCode.iloc[0]
  307. engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
  308. if isinstance(engineTypeName, pd.Series):
  309. engineTypeName = engineTypeName.iloc[0]
  310. # 构建最终的JSON对象
  311. json_output = {
  312. "analysisTypeCode": "变桨和有功功率协调性分析",
  313. "engineCode": engineTypeCode,
  314. "engineTypeName": engineTypeName,
  315. "xaixs": "桨距角(°)",
  316. "yaixs": "时间",
  317. "zaixs": "有功功率(kW)",
  318. "data": [{
  319. "engineName": name[0],
  320. "engineCode": name[1],
  321. "title": f' 月度桨距角功率3D散点图: {name[0]}',
  322. "xData": group[Field_PitchAngel1].tolist(),
  323. "yData": group[Field_YearMonth].tolist(),
  324. "zData": group[Field_ActiverPower].tolist(),
  325. "color":group[Field_YearMonth].tolist()
  326. }]
  327. }
  328. # 保存图像
  329. # filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}_3D.png")
  330. # fig.write_image(filePathOfImage, width=800, height=600, scale=3)
  331. # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}_3D.html")
  332. # fig.write_html(filePathOfHtml)
  333. # 将JSON对象保存到文件
  334. output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}_3D.json")
  335. with open(output_json_path, 'w', encoding='utf-8') as f:
  336. import json
  337. json.dump(json_output, f, ensure_ascii=False, indent=4)
  338. # result_rows2.append({
  339. # Field_Return_TypeAnalyst: self.typeAnalyst(),
  340. # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  341. # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  342. # Field_CodeOfTurbine: name[1],
  343. # Field_Return_FilePath: filePathOfImage,
  344. # Field_Return_IsSaveDatabase: False
  345. # })
  346. result_rows2.append({
  347. Field_Return_TypeAnalyst: self.typeAnalyst(),
  348. Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  349. Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  350. Field_CodeOfTurbine: name[1],
  351. Field_MillTypeCode: 'total',
  352. Field_Return_FilePath: output_json_path,
  353. Field_Return_IsSaveDatabase: True
  354. })
  355. result_df2 = pd.DataFrame(result_rows2)
  356. return result_df2
  357. # self.drawScatterGraphOfTurbine(
  358. # group, outputAnalysisDir, conf, name)
  359. # def drawScatterGraphOfTurbine(self, dataFrame: pd.DataFrame, outputAnalysisDir: str, conf: Contract, turbineName: str):
  360. # # 创建3D散点图
  361. # fig = px.scatter_3d(dataFrame,
  362. # x=Field_PitchAngel1,
  363. # y=Field_YearMonth,
  364. # z=Field_ActiverPower,
  365. # color=Field_YearMonth,
  366. # labels={Field_PitchAngel1: 'Pitch Angle',
  367. # Field_YearMonth: 'Time', Field_ActiverPower: 'Power'},
  368. # )
  369. # # 设置固定散点大小
  370. # fig.update_traces(marker=dict(size=1.5))
  371. # # 更新图形的布局
  372. # fig.update_layout(
  373. # title={
  374. # "text": f'Monthly Pitch-Power 3D Scatter Plot: {turbineName}',
  375. # "x": 0.5
  376. # },
  377. # scene=dict(
  378. # xaxis=dict(
  379. # title='Pitch Angle',
  380. # range=[conf.dataContract.graphSets["pitchAngle"]["min"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["min"]) else -2,
  381. # conf.dataContract.graphSets["pitchAngle"]["max"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["max"]) else 28],
  382. # dtick=conf.dataContract.graphSets["pitchAngle"]["step"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["step"]) else 2,
  383. # ),
  384. # yaxis=dict(
  385. # title='Time',
  386. # tickformat='%Y-%m', # 日期格式,
  387. # dtick='M1', # 每月一个刻度
  388. # showgrid=True, # 显示网格线
  389. # ),
  390. # zaxis=dict(
  391. # title='Power',
  392. # dtick=conf.dataContract.graphSets["activePower"]["step"] if not self.common.isNone(
  393. # conf.dataContract.graphSets["activePower"]) and not self.common.isNone(
  394. # conf.dataContract.graphSets["activePower"]["step"]) else 250,
  395. # range=[conf.dataContract.graphSets["activePower"]["min"] if not self.common.isNone(
  396. # conf.dataContract.graphSets["activePower"]["min"]) else 0, conf.dataContract.graphSets["activePower"]["max"] if not self.common.isNone(conf.dataContract.graphSets["activePower"]["max"]) else conf.rated_power*1.2],
  397. # showgrid=True, # 显示网格线
  398. # )
  399. # ),
  400. # scene_camera=dict(
  401. # up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  402. # center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  403. # eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  404. # ),
  405. # # 设置图例标题
  406. # legend_title_text='Time'
  407. # )
  408. # # 保存图像
  409. # outputFileHtml = os.path.join(
  410. # outputAnalysisDir, "{}_3D.html".format(turbineName))
  411. # fig.write_html(outputFileHtml)
  412. """"
  413. def drawScatterGraph(self, dataFrame: pd.DataFrame, outputAnalysisDir, conf: Contract):
  414. ## 绘制变桨-功率分布图并保存为文件。
  415. ## 参数:
  416. ## dataFrameMerge (pd.DataFrame): 包含数据的DataFrame,需要包含设备名、风速和功率列。
  417. ## outputAnalysisDir (str): 分析输出目录。
  418. ## conf (ConfBusiness): 配置
  419. ## 按设备名分组数据
  420. colorsList = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd',
  421. '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf', '#aec7e8', '#ffbb78']
  422. grouped = dataFrame.groupby(Field_NameOfTurbine)
  423. # 遍历每个设备的数据
  424. for name, group in grouped:
  425. # 创建颜色映射,将每个年月映射到一个唯一的颜色
  426. unique_months = group[Field_YearMonth].unique()
  427. colors = [
  428. colorsList[i % 12] for i in range(len(unique_months))]
  429. color_map = dict(zip(unique_months, colors))
  430. # 使用go.Scatter3d创建3D散点图
  431. trace = go.Scatter3d(
  432. x=group[Field_PitchAngel1],
  433. y=group[Field_YearMonth],
  434. z=group[Field_ActiverPower],
  435. mode='markers',
  436. marker=dict(
  437. color=[color_map[month]
  438. for month in group[Field_YearMonth]],
  439. size=1.5,
  440. line=dict(
  441. color='rgba(0, 0, 0, 0)', # 设置边框颜色为透明,以去掉白色边框
  442. width=0 # 设置边框宽度为0,进一步确保没有边框
  443. ),
  444. opacity=0.8 # 调整散点的透明度,增加透视效果
  445. )
  446. )
  447. # 创建图形
  448. fig = go.Figure(data=[trace])
  449. # 更新图形的布局
  450. fig.update_layout(
  451. title={
  452. "text": f'三维散点图{name}',
  453. "x": 0.5
  454. },
  455. scene=dict(
  456. xaxis=dict(
  457. title='桨距角',
  458. dtick=conf.dataContract.graphSets["pitchAngle"]["step"] if not self.common.isNone(
  459. conf.dataContract.graphSets["pitchAngle"]["step"]) else 2, # 设置y轴刻度间隔为0.1
  460. range=[conf.dataContract.graphSets["pitchAngle"]["min"] if not self.common.isNone(
  461. conf.dataContract.graphSets["pitchAngle"]["min"]) else -2, conf.dataContract.graphSets["pitchAngle"]["max"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["max"]) else 28], # 设置y轴的范围从0到1
  462. showgrid=True, # 显示网格线
  463. ),
  464. yaxis=dict(
  465. title='时间',
  466. tickmode='array',
  467. tickvals=unique_months,
  468. ticktext=unique_months,
  469. showgrid=True, # 显示网格线
  470. categoryorder='category ascending'
  471. ),
  472. zaxis=dict(
  473. title='功率',
  474. dtick=conf.dataContract.graphSets["activePower"]["step"] if not self.common.isNone(
  475. conf.dataContract.graphSets["activePower"]) and not self.common.isNone(
  476. conf.dataContract.graphSets["activePower"]["step"]) else 250,
  477. range=[conf.dataContract.graphSets["activePower"]["min"] if not self.common.isNone(
  478. conf.dataContract.graphSets["activePower"]["min"]) else 0, conf.dataContract.graphSets["activePower"]["max"] if not self.common.isNone(conf.dataContract.graphSets["activePower"]["max"]) else conf.rated_power*1.2],
  479. )
  480. ),
  481. scene_camera=dict(
  482. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  483. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  484. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  485. ),
  486. margin=dict(t=50, b=10) # t为顶部(top)间距,b为底部(bottom)间距
  487. )
  488. # 保存图像
  489. outputFileHtml = os.path.join(
  490. outputAnalysisDir, "{}.html".format(name))
  491. fig.write_html(outputFileHtml)
  492. """