Skip to content

Commit

Permalink
tutorial 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Guangyuan Li authored and Guangyuan Li committed Jan 3, 2021
1 parent e4ced57 commit d3e91dd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ I am planning to share how to make publication-quality figures in python, I will

1. Tutorial I (Understanding Fig and Ax object)
* link: https://towardsdatascience.com/making-publication-quality-figures-in-python-part-i-fig-and-axes-d86c3903ad9b
2. stay tuned
2. Turorial II (Line plot, colors and legends)
* Link: https://frankligy.medium.com/making-publication-quality-figures-in-python-part-ii-line-plot-legends-colors-4430a5891706
34 changes: 34 additions & 0 deletions Tutorial2_lineplot_color_legend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import numpy as np
import pandas as pd

mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42
mpl.rcParams['font.family'] = 'Arial'

np.random.seed(42)


x = np.arange(1,11,1)
y1 = np.linspace(300,400,10)
y2 = np.random.randint(low=300,high=400,size=10)

mpl.rcParams['lines.marker'] #None
mpl.rcParams['lines.markersize'] #6.0
mpl.rcParams['lines.linewidth'] # 1.5
mpl.rcParams['axes.prop_cycle']

mpl.colors.to_rgb('#1f77b4')

fig = plt.figure(figsize=(10,6))
ax = fig.add_axes([0.1,0.1,0.5,0.8])
p1 = ax.plot(x,y1,marker='o',markersize=8,markerfacecolor='red',markeredgecolor='black',markeredgewidth=2,
linestyle='--',linewidth=3,zorder=3)
p2 = ax.plot(x,y2,marker='o')
ax.legend(handles=[p1[0],p2[0]],labels=['blue line','orange line'],loc='upper left',bbox_to_anchor=(1,1),
title='legend',frameon=False)



0 comments on commit d3e91dd

Please sign in to comment.