Skip to content

Commit 2e752c2

Browse files
committed
update figures for revision
1 parent 810bfc3 commit 2e752c2

57 files changed

Lines changed: 124625 additions & 63698 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ baseline_controllers/epsilon/v2/lev1/results/constant-flow_param=0.0_data_log.pk
8686
baseline_controllers/alpha/v2/results/uncontrolled_data_log.pkl
8787
baseline_controllers/alpha/v2/lev1/results/equal-filling_param=0.0_data_log.pkl
8888
baseline_controllers/alpha/v2/lev1/results/constant-flow_param=0.0_data_log.pkl
89+
pystorms.code-workspace

baseline_controllers/alpha/compare_levels.py

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,40 @@
9898

9999
if idx == len(states_to_plot) - 2: # second to last row, for the legend
100100
ax = fig.add_subplot(gs[idx,0])
101-
ax.plot(uncontrolled_states.index[0:2], np.zeros((2,1)), label = 'Uncontrolled',color='black',alpha=0.6)
102-
ax.plot(level1_states.index[0:2], np.zeros((2,1)), label = 'Level 1',color='blue',alpha=0.6)
103-
ax.plot(level2_states.index[0:2], np.zeros((2,1)), label = 'Level 2',color='green',alpha=0.6)
104-
ax.plot(level3_states.index[0:2], np.zeros((2,1)), label = 'Level 3',color='red',alpha=0.6)
105-
ax.legend(fontsize='x-large')
101+
# Plot lines for legend (these will be used as legend handles)
102+
line1, = ax.plot([], [], label='Uncontrolled', color='black', alpha=0.6)
103+
line2, = ax.plot([], [], label='Level 1', color='blue', alpha=0.6)
104+
line3, = ax.plot([], [], label='Level 2', color='green', alpha=0.6)
105+
line4, = ax.plot([], [], label='Level 3', color='red', alpha=0.6)
106+
# Remove all spines and tick marks
107+
for spine in ax.spines.values():
108+
spine.set_visible(False)
109+
ax.tick_params(axis='both', which='both', length=0, labelleft=False, labelbottom=False)
110+
# Draw legend with an opaque background so it hides the underlying plots
111+
leg = ax.legend(handles=[line1, line2, line3, line4], fontsize='xx-large', frameon=True, loc='center')
112+
try:
113+
leg.get_frame().set_facecolor('white')
114+
leg.get_frame().set_alpha(1.0)
115+
except Exception:
116+
pass
117+
leg.set_zorder(10)
118+
# Add a white rectangle behind the legend only (figure coords) so nearby plots remain visible
119+
ax.add_patch(plt.Rectangle((-0.2, -0.2), 1.4, 1.4, transform=ax.transAxes, color='white', zorder=9))
120+
ax.set_xlim(0, 1)
121+
ax.set_ylim(0, 1)
122+
# Remove any other axes that share this gridspec location
123+
for other_ax in fig.axes:
124+
if other_ax is not ax and hasattr(other_ax, 'get_subplotspec'):
125+
try:
126+
if other_ax.get_subplotspec() == ax.get_subplotspec():
127+
other_ax.remove()
128+
except Exception:
129+
pass
130+
# clear off anything which is on another axis but on this gridspec location
131+
132+
133+
134+
106135

107136

108137
unc_perf = sum(uncontrolled_data_log['performance_measure'])

baseline_controllers/alpha/compare_timeseries.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import os
1212

1313
# ALPHA SCENARIO
14-
version = "2"
15-
level = "3"
14+
version = "1"
15+
level = "1"
1616
# set the working directory to the directory of this script
1717
os.chdir(os.path.dirname(os.path.abspath(__file__)))
1818
print(os.getcwd())
@@ -103,7 +103,23 @@
103103
ax.plot(constant_flow_states.index[0:2], np.zeros((2,1)), label = 'Constant Flow',color='red',alpha=0.6)
104104
ax.plot(structural_states.index[0:2], np.zeros((2,1)), label = 'Structural',color='green',alpha=0.6)
105105
ax.axis('off')
106-
ax.legend(fontsize='x-large')
106+
ax.legend(fontsize='xx-large')
107+
# draw the legend with zorder 10
108+
leg = ax.get_legend()
109+
leg.set_zorder(10)
110+
111+
# Add a white rectangle behind the legend only (figure coords) so nearby plots remain visible
112+
ax.add_patch(plt.Rectangle((-0.2, -0.2), 1.4, 1.4, transform=ax.transAxes, color='white', zorder=9))
113+
ax.set_xlim(0, 1)
114+
ax.set_ylim(0, 1)
115+
# Remove any other axes that share this gridspec location
116+
for other_ax in fig.axes:
117+
if other_ax is not ax and hasattr(other_ax, 'get_subplotspec'):
118+
try:
119+
if other_ax.get_subplotspec() == ax.get_subplotspec():
120+
other_ax.remove()
121+
except Exception:
122+
pass
107123

108124

109125
unc_perf = sum(uncontrolled_data_log['performance_measure'])
3.53 KB
Loading

0 commit comments

Comments
 (0)