pitchPowerAnalyst.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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. # "colorbar": dataFrameMerge[Field_YearMonth].unique().tolist(),
  140. "colorbar": dataFrameMerge[Field_YearMonth].tolist(),
  141. }]
  142. }
  143. # 保存图像
  144. # filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}.png")
  145. # fig.write_image(filePathOfImage, width=800, height=600, scale=3)
  146. # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}.html")
  147. # fig.write_html(filePathOfHtml)
  148. # 将JSON对象保存到文件
  149. output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}.json")
  150. with open(output_json_path, 'w', encoding='utf-8') as f:
  151. import json
  152. json.dump(json_output, f, ensure_ascii=False, indent=4)
  153. # result_rows1.append({
  154. # Field_Return_TypeAnalyst: self.typeAnalyst(),
  155. # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  156. # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  157. # Field_CodeOfTurbine: name[1],
  158. # Field_Return_FilePath: filePathOfImage,
  159. # Field_Return_IsSaveDatabase: False
  160. # })
  161. result_rows1.append({
  162. Field_Return_TypeAnalyst: self.typeAnalyst(),
  163. Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  164. Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  165. Field_CodeOfTurbine: name[1],
  166. Field_MillTypeCode: 'total',
  167. Field_Return_FilePath: output_json_path,
  168. Field_Return_IsSaveDatabase: True
  169. })
  170. result_df1 = pd.DataFrame(result_rows1)
  171. return result_df1
  172. def drawScatterGraph(self, dataFrame: pd.DataFrame, turbineModelInfo: pd.Series, outputAnalysisDir: str, conf: Contract):
  173. dataFrame = dataFrame[(dataFrame[Field_ActiverPower] > 0)].sort_values(
  174. by=Field_YearMonth)
  175. grouped = dataFrame.groupby([Field_NameOfTurbine, Field_CodeOfTurbine])
  176. '''
  177. # 遍历每个设备的数据
  178. result_rows2 = []
  179. for name, group in grouped:
  180. if len(group[Field_YearMonth].unique()) > 1:
  181. fig = px.scatter_3d(dataFrame,
  182. x=Field_PitchAngel1,
  183. y=Field_YearMonth,
  184. z=Field_ActiverPower,
  185. color=Field_YearMonth,
  186. labels={Field_PitchAngel1: '桨距角',
  187. Field_YearMonth: '时间', Field_ActiverPower: '功率'},
  188. )
  189. # 设置固定散点大小
  190. fig.update_traces(marker=dict(size=1.5))
  191. # 更新图形的布局
  192. fig.update_layout(
  193. title={
  194. "text": f'月度桨距角功率3D散点图: {name[0]}',
  195. "x": 0.5
  196. },
  197. scene=dict(
  198. xaxis=dict(
  199. title='桨距角',
  200. dtick=self.axisStepPitchAngle,
  201. range=[self.axisLowerLimitPitchAngle,
  202. self.axisUpperLimitPitchAngle],
  203. ),
  204. yaxis=dict(
  205. title='时间',
  206. tickformat='%Y-%m', # 日期格式,
  207. dtick='M1', # 每月一个刻度
  208. showgrid=True, # 显示网格线
  209. ),
  210. zaxis=dict(
  211. title='功率',
  212. dtick=self.axisStepActivePower,
  213. range=[self.axisLowerLimitActivePower,
  214. self.axisUpperLimitActivePower],
  215. showgrid=True, # 显示网格线
  216. )
  217. ),
  218. scene_camera=dict(
  219. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  220. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  221. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  222. ),
  223. # 设置图例标题
  224. # legend_title_text='Time',
  225. legend=dict(
  226. orientation="h",
  227. itemsizing="constant", # Use constant size for legend items
  228. itemwidth=80 # Set the width of legend items to 50 pixels
  229. )
  230. )
  231. '''
  232. # 假设 colorsList 已经在代码的其他部分定义
  233. colorsList = [
  234. "#3E409C",
  235. "#3586BF",
  236. "#52A3AE",
  237. "#85D0AE",
  238. "#A8DCA2",
  239. "#FBFFBE",
  240. "#FDF1A9",
  241. "#FFE286",
  242. "#FCB06C",
  243. "#F96F4A",
  244. "#E4574C",
  245. "#AF254F"
  246. ]
  247. # 遍历每个设备的数据
  248. result_rows2 = []
  249. for name, group in grouped:
  250. if len(group[Field_YearMonth].unique()) > 1:
  251. fig = px.scatter_3d(
  252. group,
  253. x=Field_PitchAngel1,
  254. y=Field_YearMonth,
  255. z=Field_ActiverPower,
  256. color=Field_YearMonth,
  257. color_discrete_sequence=colorsList, # 使用 colorsList 作为颜色映射
  258. labels={
  259. Field_PitchAngel1: '桨距角',
  260. Field_YearMonth: '时间',
  261. Field_ActiverPower: '功率'
  262. },
  263. )
  264. # 设置固定散点大小
  265. fig.update_traces(marker=dict(size=1.5))
  266. # 更新图形的布局
  267. fig.update_layout(
  268. title={
  269. "text": f'月度桨距角功率3D散点图: {name[0]}',
  270. "x": 0.5
  271. },
  272. scene=dict(
  273. xaxis=dict(
  274. title='桨距角',
  275. dtick=self.axisStepPitchAngle,
  276. range=[self.axisLowerLimitPitchAngle, self.axisUpperLimitPitchAngle],
  277. ),
  278. yaxis=dict(
  279. title='时间',
  280. tickformat='%Y-%m', # 日期格式,
  281. dtick='M1', # 每月一个刻度
  282. showgrid=True, # 显示网格线
  283. ),
  284. zaxis=dict(
  285. title='功率',
  286. dtick=self.axisStepActivePower,
  287. range=[self.axisLowerLimitActivePower, self.axisUpperLimitActivePower],
  288. showgrid=True, # 显示网格线
  289. )
  290. ),
  291. scene_camera=dict(
  292. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  293. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  294. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  295. ),
  296. legend=dict(
  297. orientation="h",
  298. itemsizing="constant", # Use constant size for legend items
  299. itemwidth=80 # Set the width of legend items to 50 pixels
  300. )
  301. )
  302. # 确保从 Series 中提取的是具体的值
  303. engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
  304. if isinstance(engineTypeCode, pd.Series):
  305. engineTypeCode = engineTypeCode.iloc[0]
  306. engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
  307. if isinstance(engineTypeName, pd.Series):
  308. engineTypeName = engineTypeName.iloc[0]
  309. # 构建最终的JSON对象
  310. json_output = {
  311. "analysisTypeCode": "变桨和有功功率协调性分析",
  312. "engineCode": engineTypeCode,
  313. "engineTypeName": engineTypeName,
  314. "xaixs": "桨距角(°)",
  315. "yaixs": "时间",
  316. "zaixs": "有功功率(kW)",
  317. "data": [{
  318. "engineName": name[0],
  319. "engineCode": name[1],
  320. "title": f' 月度桨距角功率3D散点图: {name[0]}',
  321. "xData": group[Field_PitchAngel1].tolist(),
  322. "yData": group[Field_YearMonth].tolist(),
  323. "zData": group[Field_ActiverPower].tolist(),
  324. "color":group[Field_YearMonth].tolist()
  325. }]
  326. }
  327. # 保存图像
  328. # filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}_3D.png")
  329. # fig.write_image(filePathOfImage, width=800, height=600, scale=3)
  330. # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}_3D.html")
  331. # fig.write_html(filePathOfHtml)
  332. # 将JSON对象保存到文件
  333. output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}_3D.json")
  334. with open(output_json_path, 'w', encoding='utf-8') as f:
  335. import json
  336. json.dump(json_output, f, ensure_ascii=False, indent=4)
  337. # result_rows2.append({
  338. # Field_Return_TypeAnalyst: self.typeAnalyst(),
  339. # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  340. # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  341. # Field_CodeOfTurbine: name[1],
  342. # Field_Return_FilePath: filePathOfImage,
  343. # Field_Return_IsSaveDatabase: False
  344. # })
  345. result_rows2.append({
  346. Field_Return_TypeAnalyst: self.typeAnalyst(),
  347. Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  348. Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  349. Field_CodeOfTurbine: name[1],
  350. Field_MillTypeCode: 'total',
  351. Field_Return_FilePath: output_json_path,
  352. Field_Return_IsSaveDatabase: True
  353. })
  354. result_df2 = pd.DataFrame(result_rows2)
  355. return result_df2
  356. # self.drawScatterGraphOfTurbine(
  357. # group, outputAnalysisDir, conf, name)
  358. # def drawScatterGraphOfTurbine(self, dataFrame: pd.DataFrame, outputAnalysisDir: str, conf: Contract, turbineName: str):
  359. # # 创建3D散点图
  360. # fig = px.scatter_3d(dataFrame,
  361. # x=Field_PitchAngel1,
  362. # y=Field_YearMonth,
  363. # z=Field_ActiverPower,
  364. # color=Field_YearMonth,
  365. # labels={Field_PitchAngel1: 'Pitch Angle',
  366. # Field_YearMonth: 'Time', Field_ActiverPower: 'Power'},
  367. # )
  368. # # 设置固定散点大小
  369. # fig.update_traces(marker=dict(size=1.5))
  370. # # 更新图形的布局
  371. # fig.update_layout(
  372. # title={
  373. # "text": f'Monthly Pitch-Power 3D Scatter Plot: {turbineName}',
  374. # "x": 0.5
  375. # },
  376. # scene=dict(
  377. # xaxis=dict(
  378. # title='Pitch Angle',
  379. # range=[conf.dataContract.graphSets["pitchAngle"]["min"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["min"]) else -2,
  380. # conf.dataContract.graphSets["pitchAngle"]["max"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["max"]) else 28],
  381. # dtick=conf.dataContract.graphSets["pitchAngle"]["step"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["step"]) else 2,
  382. # ),
  383. # yaxis=dict(
  384. # title='Time',
  385. # tickformat='%Y-%m', # 日期格式,
  386. # dtick='M1', # 每月一个刻度
  387. # showgrid=True, # 显示网格线
  388. # ),
  389. # zaxis=dict(
  390. # title='Power',
  391. # dtick=conf.dataContract.graphSets["activePower"]["step"] if not self.common.isNone(
  392. # conf.dataContract.graphSets["activePower"]) and not self.common.isNone(
  393. # conf.dataContract.graphSets["activePower"]["step"]) else 250,
  394. # range=[conf.dataContract.graphSets["activePower"]["min"] if not self.common.isNone(
  395. # 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],
  396. # showgrid=True, # 显示网格线
  397. # )
  398. # ),
  399. # scene_camera=dict(
  400. # up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  401. # center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  402. # eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  403. # ),
  404. # # 设置图例标题
  405. # legend_title_text='Time'
  406. # )
  407. # # 保存图像
  408. # outputFileHtml = os.path.join(
  409. # outputAnalysisDir, "{}_3D.html".format(turbineName))
  410. # fig.write_html(outputFileHtml)
  411. """"
  412. def drawScatterGraph(self, dataFrame: pd.DataFrame, outputAnalysisDir, conf: Contract):
  413. ## 绘制变桨-功率分布图并保存为文件。
  414. ## 参数:
  415. ## dataFrameMerge (pd.DataFrame): 包含数据的DataFrame,需要包含设备名、风速和功率列。
  416. ## outputAnalysisDir (str): 分析输出目录。
  417. ## conf (ConfBusiness): 配置
  418. ## 按设备名分组数据
  419. colorsList = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd',
  420. '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf', '#aec7e8', '#ffbb78']
  421. grouped = dataFrame.groupby(Field_NameOfTurbine)
  422. # 遍历每个设备的数据
  423. for name, group in grouped:
  424. # 创建颜色映射,将每个年月映射到一个唯一的颜色
  425. unique_months = group[Field_YearMonth].unique()
  426. colors = [
  427. colorsList[i % 12] for i in range(len(unique_months))]
  428. color_map = dict(zip(unique_months, colors))
  429. # 使用go.Scatter3d创建3D散点图
  430. trace = go.Scatter3d(
  431. x=group[Field_PitchAngel1],
  432. y=group[Field_YearMonth],
  433. z=group[Field_ActiverPower],
  434. mode='markers',
  435. marker=dict(
  436. color=[color_map[month]
  437. for month in group[Field_YearMonth]],
  438. size=1.5,
  439. line=dict(
  440. color='rgba(0, 0, 0, 0)', # 设置边框颜色为透明,以去掉白色边框
  441. width=0 # 设置边框宽度为0,进一步确保没有边框
  442. ),
  443. opacity=0.8 # 调整散点的透明度,增加透视效果
  444. )
  445. )
  446. # 创建图形
  447. fig = go.Figure(data=[trace])
  448. # 更新图形的布局
  449. fig.update_layout(
  450. title={
  451. "text": f'三维散点图{name}',
  452. "x": 0.5
  453. },
  454. scene=dict(
  455. xaxis=dict(
  456. title='桨距角',
  457. dtick=conf.dataContract.graphSets["pitchAngle"]["step"] if not self.common.isNone(
  458. conf.dataContract.graphSets["pitchAngle"]["step"]) else 2, # 设置y轴刻度间隔为0.1
  459. range=[conf.dataContract.graphSets["pitchAngle"]["min"] if not self.common.isNone(
  460. 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
  461. showgrid=True, # 显示网格线
  462. ),
  463. yaxis=dict(
  464. title='时间',
  465. tickmode='array',
  466. tickvals=unique_months,
  467. ticktext=unique_months,
  468. showgrid=True, # 显示网格线
  469. categoryorder='category ascending'
  470. ),
  471. zaxis=dict(
  472. title='功率',
  473. dtick=conf.dataContract.graphSets["activePower"]["step"] if not self.common.isNone(
  474. conf.dataContract.graphSets["activePower"]) and not self.common.isNone(
  475. conf.dataContract.graphSets["activePower"]["step"]) else 250,
  476. range=[conf.dataContract.graphSets["activePower"]["min"] if not self.common.isNone(
  477. 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],
  478. )
  479. ),
  480. scene_camera=dict(
  481. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  482. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  483. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  484. ),
  485. margin=dict(t=50, b=10) # t为顶部(top)间距,b为底部(bottom)间距
  486. )
  487. # 保存图像
  488. outputFileHtml = os.path.join(
  489. outputAnalysisDir, "{}.html".format(name))
  490. fig.write_html(outputFileHtml)
  491. """