-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal_q_bar_plot.py
More file actions
79 lines (75 loc) · 2.18 KB
/
Copy pathfinal_q_bar_plot.py
File metadata and controls
79 lines (75 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# %%
import time
import plotly.io as pio
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
color_set = pio.templates['seaborn'].layout.colorway
# color = color_set[offsetgroup % len(color_set)]
q_df = pd.DataFrame({
'Case': [1, 2, 3, 4, 5],
'Ideal': [450, 360, 300, 250, 135],
'D-OPF': [473, 378, 322, 275, 177],
'ACA': [389, 298, 237, 187, 73],
'CA': [374, 324, 281, 235, 132],
})
df = q_df.melt(id_vars=['Case'], value_vars=['Ideal', 'D-OPF', 'ACA', 'CA'], var_name='Algorithm', value_name='Q')
# fig = px.bar(
# q_df, x='Case', y='Q',
# color='Algorithm',
# barmode='group',
# title='Total Q Injection (kVAr)',
# template='seaborn',)
#
# fig.show(renderer='browser')
fig = go.Figure()
patterns = ['.', '/', '\\']
for i, algorithm in enumerate(['D-OPF', 'ACA', 'CA']):
offsetgroup = i
color_set = pio.templates['seaborn'].layout.colorway
color = color_set[offsetgroup % len(color_set)]
fig.add_trace(
go.Bar(
name=algorithm,
x=df.Case,
y=df[df['Algorithm'] == algorithm]['Q'],
marker=go.bar.Marker(color=color, line=dict(width=4, color='black')),
marker_pattern_shape=patterns[i],
# offsetgroup=offsetgroup,
# legendgroup=offsetgroup,
showlegend=True,
# text='a',
),
)
fig.add_trace(
go.Scatter(
name='Ideal',
x=df.Case,
y=df[df['Algorithm'] == 'Ideal']['Q'],
mode='markers',
marker_symbol="diamond",
marker_size=10,
marker_color="black"
)
)
fig.update_layout(
font_family="Times New Roman",
font_size=24,
template='seaborn',
margin=dict(l=10, r=10, t=10, b=10),
)
fig.update_xaxes(title_text='Case')
fig.update_yaxes(title_text='Substation Q Load (kVAr)')
fig.show(renderer='browser')
fig_dummy = go.Figure()
fig_dummy.write_image('dummy.pdf', format="pdf")
time.sleep(1)
fig.write_image('q_support.pdf',
width=600,
height=600,
)
fig.write_image('q_support.png',
width=600,
height=500,
)