Last active
October 5, 2017 11:24
-
-
Save InnerPeace-Wu/adbeeff203f4b119cb56a24ae002c89e to your computer and use it in GitHub Desktop.
tips of using matplot.lib.pyplot in python 2.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(16, 9)) | |
plt.subplot(1, 2, 1) | |
plt.hist(data, normed=True, bins=30) | |
plt.subplot(1, 2, 2) | |
#plot things... | |
plt.xlabel('x') | |
plt.ylabel('y') | |
plt.title('tile') | |
#add legend | |
plt.legend(['t1, t2'], loc='upper right']) | |
fig.tight_layout() | |
file_name = 'name.pdf' | |
plt.savefig(file_name, format='pdf') | |
#or | |
plt.savefig('name.png', dpi=100) | |
#maximize window before tf.show() | |
import matplotlib | |
matplotlib.get_backend() | |
#Option 1 | |
#QT backend | |
manager = plt.get_current_fig_manager() | |
manager.window.showMaximized() | |
#Option 2 | |
#TkAgg backend | |
manager = plt.get_current_fig_manager() | |
manager.resize(*manager.window.maxsize()) | |
#Option 3 | |
#WX backend | |
manager = plt.get_current_fig_manager() | |
manager.frame.Maximize(True) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment