diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index 3f36d643a6..f6f237c706 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -32,8 +32,16 @@ ax = plt.subplot(1, 1, 1, projection='polar') # draw the analemma loops points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, - s=2, label=None, c=solpos.index.dayofyear) -ax.figure.colorbar(points) + s=2, label=None, c=solpos.index.dayofyear, + cmap='twilight_shifted_r') +# add and format colorbar +cbar = ax.figure.colorbar(points) +times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) +cbar.set_ticks(ticks=times_ticks.dayofyear, labels=[], minor=False) +cbar.set_ticks(ticks=times_ticks.dayofyear+15, + labels=times_ticks.strftime('%b'), + minor=True) +cbar.ax.tick_params(which='minor', width=0) # draw hour labels for hour in np.unique(solpos.index.hour): @@ -41,14 +49,15 @@ subset = solpos.loc[solpos.index.hour == hour, :] r = subset.apparent_zenith pos = solpos.loc[r.idxmin(), :] - ax.text(np.radians(pos['azimuth']), pos['apparent_zenith'], str(hour)) + ax.text(np.radians(pos['azimuth']), pos['apparent_zenith'], + str(hour).zfill(2), ha='center', va='bottom') # draw individual days for date in pd.to_datetime(['2019-03-21', '2019-06-21', '2019-12-21']): times = pd.date_range(date, date+pd.Timedelta('24h'), freq='5min', tz=tz) solpos = solarposition.get_solarposition(times, lat, lon) solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] - label = date.strftime('%Y-%m-%d') + label = date.strftime('%b %d') ax.plot(np.radians(solpos.azimuth), solpos.apparent_zenith, label=label) ax.figure.legend(loc='upper left') @@ -64,7 +73,7 @@ # This is a polar plot of hourly solar zenith and azimuth. The figure-8 # patterns are called `analemmas `_ and # show how the sun's path slowly shifts over the course of the year . The -# colored lines show the single-day sun paths for the winter and summer +# solid colored lines show the single-day sun paths for the winter and summer # solstices as well as the spring equinox. # # The soltice paths mark the boundary of the sky area that the sun traverses @@ -111,25 +120,37 @@ fig, ax = plt.subplots() points = ax.scatter(solpos.azimuth, solpos.apparent_elevation, s=2, - c=solpos.index.dayofyear, label=None) -fig.colorbar(points) + c=solpos.index.dayofyear, label=None, + cmap='twilight_shifted_r') +# add and format colorbar +cbar = fig.colorbar(points) +times_ticks = pd.date_range('2019-01-01', '2020-01-01', freq='MS', tz=tz) +cbar.set_ticks(ticks=times_ticks.dayofyear, labels=[], minor=False) +cbar.set_ticks(ticks=times_ticks.dayofyear+15, + labels=times_ticks.strftime('%b'), + minor=True) +cbar.ax.tick_params(which='minor', width=0) for hour in np.unique(solpos.index.hour): # choose label position by the largest elevation for each hour subset = solpos.loc[solpos.index.hour == hour, :] height = subset.apparent_elevation pos = solpos.loc[height.idxmax(), :] - ax.text(pos['azimuth'], pos['apparent_elevation'], str(hour)) + azimuth_offset = -10 if pos['azimuth'] < 180 else 10 + ax.text(pos['azimuth']+azimuth_offset, pos['apparent_elevation'], + str(hour).zfill(2), ha='center', va='bottom') for date in pd.to_datetime(['2019-03-21', '2019-06-21', '2019-12-21']): times = pd.date_range(date, date+pd.Timedelta('24h'), freq='5min', tz=tz) solpos = solarposition.get_solarposition(times, lat, lon) solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] - label = date.strftime('%Y-%m-%d') + label = date.strftime('%d %b') ax.plot(solpos.azimuth, solpos.apparent_elevation, label=label) -ax.figure.legend(loc='upper left') +ax.figure.legend(loc='upper center', bbox_to_anchor=[0.45, 1], ncols=3) ax.set_xlabel('Solar Azimuth (degrees)') ax.set_ylabel('Solar Elevation (degrees)') +ax.set_xticks([0, 90, 180, 270, 360]) +ax.set_ylim(0, None) plt.show() diff --git a/docs/sphinx/source/whatsnew/v0.11.0.rst b/docs/sphinx/source/whatsnew/v0.11.0.rst index b306654624..005b750315 100644 --- a/docs/sphinx/source/whatsnew/v0.11.0.rst +++ b/docs/sphinx/source/whatsnew/v0.11.0.rst @@ -87,3 +87,4 @@ Contributors * Ioannis Sifnaios (:ghuser:`IoannisSifnaios`) * Mark Campanelli (:ghuser:`markcampanelli`) * Rajiv Daxini (:ghuser:`RDaxini`) +* :ghuser:`PhilBrk8`