-
-
Save amallia/0c8f166ca8edb0c26a6b7f84c7b1ef96 to your computer and use it in GitHub Desktop.
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 | |
import matplotlib.patches as mpatches | |
import matplotlib.lines as mlines | |
## All plt.rcParams lines are defined globally for all the following plots. | |
# Use latex to produce it and use the ACM default sans-serif package | |
plt.rcParams['text.usetex'] = True | |
plt.rcParams['text.latex.preamble'] = r'\usepackage{libertine}\usepackage{fixltx2e}' | |
plt.rcParams['font.family'] = "sans-serif" | |
# Lines, grids, and colors. | |
plt.rcParams['axes.linewidth'] = 0.5 | |
plt.rcParams['axes.axisbelow'] = True | |
plt.rcParams['lines.linewidth'] = 0.5 | |
plt.rcParams['patch.linewidth'] = 0.5 | |
plt.rcParams['axes.grid'] = True | |
plt.rcParams['grid.alpha'] = 0.5 | |
plt.rcParams['grid.linestyle'] = '-' | |
plt.rcParams['grid.linewidth'] = 0.2 | |
plt.rcParams['hist.bins'] = 'auto' | |
plt.rcParams['font.size'] = 8 | |
colors = plt.get_cmap('tab10').colors | |
plt.plot(x1, y1, '.-', color=colors[0], label='Plot 1', markersize=2) | |
plt.plot(x2, y2, '.-', color=colors[1], label='Plot 2', markersize=2) | |
plt.legend() | |
plt.title('Plot Example', fontsize=9) | |
plt.xlabel('X axis') | |
plt.ylabel('Y axis') | |
# Have to define ticks in order to use the latex font. | |
xticks = [0, 5, 10, 15, 20] | |
yticks = [0.08, 0.09, 0.1, 0.11, 0.12] | |
plt.xticks(xticks, xticks, fontsize=8) | |
plt.yticks(yticks, yticks, fontsize=8) | |
fig = plt.gcf() | |
fig.subplots_adjust(bottom=0.15, left=0.15) | |
fig.set_size_inches((3.3, 2.5)) | |
plt.savefig('example.pdf') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment