import matplotlib.pyplot as plt
import seaborn as sns
%pylab inline
pylab.rcParams['figure.figsize'] = (10.0, 10.0)
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
fig, ax = plt.subplots()
# The plot function
plt.plot(x_values, y_values, color='#009933', linestyle='--', linewidth=1.5)
# plot markers
plt.plot(..., marker='o', markevery=50, markerfacecolor='GreenYellow', markersize=10.0)
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# Thicks & scales
plt.xticks(x_ticks, x_ticks_lbl, rotation=60)
ax.get_yaxis().set_major_formatter(plt.FuncFormatter(lambda x, loc: "{:,}".format(int(x))))
# Grid
plt.grid()
# Boundaries
plt.xlim(right=30)
plt.ylim(top=150)
# Save & show
fig.savefig("img.png", bbox_inches="tight")
plt.show()
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# Title, labels and legend
plt.title('Title')
plt.xlabel('x_label') # use $...$ for LaTeX context
plt.ylabel('y_label')
plt.legend(['legen_plot1', 'legend_plot2'], loc='lower left' | bbox_to_anchor=(0.75, 0.8))
plt.legend((line1, line2, line3), ('label1', 'label2', 'label3')) # full control
# Format
base_fsize = 14
plt.rc('font', size=base_fsize) # controls default text sizes
plt.rc('axes', titlesize=base_fsize) # fontsize of the axes title
plt.rc('axes', labelsize=base_fsize+4) # fontsize of the x and y labels
plt.rc('xtick', labelsize=base_fsize) # fontsize of the tick labels
plt.rc('ytick', labelsize=base_fsize) # fontsize of the tick labels
plt.rc('legend', fontsize=base_fsize) # legend fontsize