From f0202e78c5df683fb7cc847edb6785e6f2e7e0a6 Mon Sep 17 00:00:00 2001 From: PhilBrk8 <92030164+PhilBrk8@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:02:07 +0100 Subject: [PATCH 1/2] changed colorbar for plots in plot_sunpath_diagrams.py The scale for the colorbar was numerical from 0-365. The monthly scale in Short month names is much more intuitive for me. --- .../solar-position/plot_sunpath_diagrams.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index 618d5f9792..e1f6fcfed3 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -31,9 +31,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) +points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, s=2, label=None, c=solpos.index.dayofyear) +# Create colorbar +cbar = ax.figure.colorbar(points) +# Define ticks for the middle of each month (assuming non-leap year for simplicity) +month_ticks = [pd.Timestamp(f'2023-{month}-15').dayofyear for month in range(1, 13)] +# Set colorbar ticks +cbar.set_ticks(month_ticks) +# Set colorbar tick labels to short month names +month_names = [pd.Timestamp(f'2023-{month}-15').strftime('%b') for month in range(1, 13)] +cbar.set_ticklabels(month_names) # draw hour labels for hour in np.unique(solpos.index.hour): @@ -111,9 +118,16 @@ solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] fig, ax = plt.subplots() -points = ax.scatter(solpos.azimuth, solpos.apparent_elevation, s=2, - c=solpos.index.dayofyear, label=None) -fig.colorbar(points) +points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, s=2, label=None, c=solpos.index.dayofyear) +# Create colorbar +cbar = ax.figure.colorbar(points) +# Define ticks for the middle of each month (assuming non-leap year for simplicity) +month_ticks = [pd.Timestamp(f'2023-{month}-15').dayofyear for month in range(1, 13)] +# Set colorbar ticks +cbar.set_ticks(month_ticks) +# Set colorbar tick labels to short month names +month_names = [pd.Timestamp(f'2023-{month}-15').strftime('%b') for month in range(1, 13)] +cbar.set_ticklabels(month_names) for hour in np.unique(solpos.index.hour): # choose label position by the largest elevation for each hour From e0a258fb85bd3c71ef7ebf557ab88bb33577caf4 Mon Sep 17 00:00:00 2001 From: PhilBrk8 <92030164+PhilBrk8@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:56:36 +0100 Subject: [PATCH 2/2] Update plot_sunpath_diagrams.py addressed linter-issues (line length) --- .../solar-position/plot_sunpath_diagrams.py | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/docs/examples/solar-position/plot_sunpath_diagrams.py b/docs/examples/solar-position/plot_sunpath_diagrams.py index e1f6fcfed3..ed887ab1a6 100644 --- a/docs/examples/solar-position/plot_sunpath_diagrams.py +++ b/docs/examples/solar-position/plot_sunpath_diagrams.py @@ -31,15 +31,27 @@ 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) +points = ax.scatter( + np.radians(solpos.azimuth), + solpos.apparent_zenith, + s=2, + label=None, + c=solpos.index.dayofyear +) # Create colorbar cbar = ax.figure.colorbar(points) -# Define ticks for the middle of each month (assuming non-leap year for simplicity) -month_ticks = [pd.Timestamp(f'2023-{month}-15').dayofyear for month in range(1, 13)] +# Define ticks for the middle of each month +month_ticks = [ + pd.Timestamp(f'2023-{month}-15') + .dayofyear for month in range(1, 13) +] # Set colorbar ticks cbar.set_ticks(month_ticks) # Set colorbar tick labels to short month names -month_names = [pd.Timestamp(f'2023-{month}-15').strftime('%b') for month in range(1, 13)] +month_names = [ + pd.Timestamp(f'2023-{month}-15') + .strftime('%b') for month in range(1, 13) +] cbar.set_ticklabels(month_names) # draw hour labels @@ -118,15 +130,27 @@ solpos = solpos.loc[solpos['apparent_elevation'] > 0, :] fig, ax = plt.subplots() -points = ax.scatter(np.radians(solpos.azimuth), solpos.apparent_zenith, s=2, label=None, c=solpos.index.dayofyear) +points = ax.scatter( + np.radians(solpos.azimuth), + solpos.apparent_zenith, + s=2, + label=None, + c=solpos.index.dayofyear +) # Create colorbar cbar = ax.figure.colorbar(points) -# Define ticks for the middle of each month (assuming non-leap year for simplicity) -month_ticks = [pd.Timestamp(f'2023-{month}-15').dayofyear for month in range(1, 13)] +# Define ticks for the middle of each month +month_ticks = [ + pd.Timestamp(f'2023-{month}-15') + .dayofyear for month in range(1, 13) +] # Set colorbar ticks -cbar.set_ticks(month_ticks) +cbar.set_ticks(month_ticks) # Set colorbar tick labels to short month names -month_names = [pd.Timestamp(f'2023-{month}-15').strftime('%b') for month in range(1, 13)] +month_names = [ + pd.Timestamp(f'2023-{month}-15') + .strftime('%b') for month in range(1, 13) +] cbar.set_ticklabels(month_names) for hour in np.unique(solpos.index.hour):