WindRoseAxes生成轴不完整问题求助
WindRoseAxes生成轴不完整问题求助
我之前代码运行一直正常,从未出现过WindRoseAxes生成的轴不完整的问题。目前不清楚需要提供哪些细节来解决问题,还请告知。
环境信息
- Python版本:3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
- matplotlib版本:3.7.5
问题截图
轴不完整的风玫瑰图:图中风玫瑰的部分坐标轴未完整显示,存在缺失情况。
测试数据
有测试用CSV数据可用于复现该问题。
代码示例
from windrose import WindroseAxes from matplotlib import pyplot as plt import matplotlib.cm as cm import numpy as np import os import matplotlib.pyplot as plt file_path = 'the directory with csv file' # 处理目录下所有csv文件 has_legend = False files = os.listdir(file_path) def create_rose(file_name): # 定义风速和风向变量 # CSV数据结构:Date , Time , Speed , Direction csv = np.genfromtxt(file_path + file_name, delimiter =',', skip_header =1) pdf_1 = file_path + 'with_legend_'+ file_name + '.pdf' pdf_2 = file_path + 'no_legend_'+ file_name + '.pdf' # ws: 风速 # wd: 风向 # Python索引从0开始 # ws = csv[ : , 2] ws = csv[ : , 0] wd = csv[ : , 1] + 15 speed_bin = np.arange(0, 4, 0.5) len(ws) ax = WindroseAxes.from_ax() ax.bar(wd, ws, normed =True, opening=1, edgecolor='white', bins = speed_bin, cmap = cm.jet, nsector = 12) ax.set_xticklabels([90, 45, 0, 315, 270, 225, 180, 135]) if(has_legend): ax.set_legend() ax.legend(loc ='lower right', decimal_places=2) plt.savefig(pdf_1) else: plt.savefig(pdf_2) for file_x in files: print(file_x) create_rose(file_x) print('All is finished')
内容的提问来源于stack exchange,提问作者Justin
相关产品推荐
相关产品推荐

