Skip to content

Instantly share code, notes, and snippets.

@CnrLwlss
Created March 4, 2016 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CnrLwlss/9587f615a7440113430c to your computer and use it in GitHub Desktop.
Save CnrLwlss/9587f615a7440113430c to your computer and use it in GitHub Desktop.
Preparing differently sized plot panels, labelled with proper genetics nomenclature, using matplotlib.
import matplotlib as mp
import matplotlib.pyplot as plt
import numpy as np
import string
# Set font for figure according to journal specs
mp.rcParams['font.family'] = "Arial"
# Gene deletion names read from file might not necessarily be in lower case
gnames=["EXO1","RAD9","TMA20"]
# Convert to standard genetics nomenclature: lowercase with delta (set italics below)
stdgens=[gname.lower()+r"$\Delta$" for gname in gnames]
# Varying plot sizes
plotsizes=[[6,12],[6,6],[6,6]]
# Different colours
cmap=plt.get_cmap("Paired") # http://matplotlib.org/examples/color/colormaps_reference.html
colors = [cmap(i) for i in np.linspace(0, 1, len(gnames))]
for i,(plotsize,gname) in enumerate(zip(plotsizes,stdgens)):
# Generate some fake data to plot
t=np.random.normal(0,1,100)
x=np.random.normal(0,1,100)
plt.figure(figsize=plotsize)
plt.scatter(t,x,edgecolors="face",c=colors[i])
plt.xlim(-5,5)
plt.ylim(-5,5)
plt.xlabel("t",fontsize=24)
plt.ylabel("x(t)",fontsize=24)
plt.tick_params(axis="both",size=12,labelsize=16)
plt.title(gname,fontsize=24,style="italic") # Specify font style here
panel_label=string.ascii_uppercase[i]
plt.savefig("plotDemo{}.pdf".format(panel_label))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment