Skip to content

Commit 515a652

Browse files
committed
adjust pdf savefig for pfss plot
1 parent a755763 commit 515a652

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

solarmach/__init__.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,16 +1126,14 @@ def add_arrow_to_legend(legend):
11261126
# restore initial rcParams that have been saved at the beginning of this function:
11271127
plt.rcParams.update(initial_rcparams)
11281128

1129-
# if using streamlit, send plot to streamlit output, else call plt.show()
1130-
if _isstreamlit():
1131-
import streamlit as st
1132-
# don't display figure if saving as pdf file in streamlit
1133-
if outfile.split('.')[-1] == 'pdf':
1134-
pass
1135-
else:
1129+
# don't display figure if saving as pdf file
1130+
if outfile.split('.')[-1] != 'pdf':
1131+
# if using streamlit, send plot to streamlit output, else call plt.show()
1132+
if _isstreamlit():
1133+
import streamlit as st
11361134
st.pyplot(fig) # , dpi=200)
1137-
else:
1138-
plt.show()
1135+
else:
1136+
plt.show()
11391137

11401138
if return_plot_object:
11411139
# TODO: not really straightforward; change in future
@@ -1686,7 +1684,10 @@ def plot_pfss(self,
16861684
if markers:
16871685
offset = matplotlib.text.OffsetFrom(leg1, (0.0, 1.0))
16881686
for i, body_id in enumerate(self.body_dict):
1689-
yoffset = i*18.7 # 18.5 19.5
1687+
if outfile.split('.')[-1] == 'pdf':
1688+
yoffset = i*19.25 # 18.5 19.5
1689+
else:
1690+
yoffset = i*18.7 # 18.5 19.5
16901691
if markers.lower()=='letters':
16911692
if body_id[:6] == 'STEREO':
16921693
mark = str(body_id[-1])
@@ -1783,12 +1784,14 @@ def legend_arrow(width, height, **_):
17831784
if outfile != '':
17841785
plt.savefig(outfile, bbox_inches="tight")
17851786

1786-
# if using streamlit, send plot to streamlit output, else call plt.show()
1787-
if _isstreamlit():
1788-
import streamlit as st
1789-
st.pyplot(fig) # , dpi=200)
1790-
else:
1791-
plt.show()
1787+
# don't display figure if saving as pdf file
1788+
if outfile.split('.')[-1] != 'pdf':
1789+
# if using streamlit, send plot to streamlit output, else call plt.show()
1790+
if _isstreamlit():
1791+
import streamlit as st
1792+
st.pyplot(fig) # , dpi=200)
1793+
else:
1794+
plt.show()
17921795

17931796
if return_plot_object:
17941797
return fig, ax

0 commit comments

Comments
 (0)