我想在极坐标图中绘制几年的日平均温度。我到了那里,但到目前为止,经过一年多的数据,线条颜色保持不变,尚不清楚哪个部分属于哪一年。因此,我想不断改变线条的颜色。我找不到这个选项。
这里是极坐标图的代码。 谢谢你的帮助
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
# Create polar plot
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
# Set tick positions and labels for the angle axis
months = mdates.MonthLocator() # every month
months_fmt = mdates.DateFormatter('%b') # month abbreviation
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(months_fmt)
# Convert dates to angles in radians
#angles = np.deg2rad((weather21_day.index).days * 360 / 365)
# Subtract January 1st from each datetime
delta = (temp_av_day.index - pd.Timestamp('2021-01-01 00:00:00+00:00') )/ np.timedelta64(1, 'D')
days_diff = np.asarray(delta)
angles = np.deg2rad(days_diff * 360 / 365)
#Plot temperature as radius
ax.plot(angles, temp_av_day['T out']+20)
#ax.plot(angles, weather22_day['T out']+20)
# Show the plot
plt.show()