Written on February 19, 2020

A KIT-ish style sheet for matplotlib

Below is a matplotlib style sheet that gives plots a KIT-ish feel. The pasted file below can be saved under ~/.config/matplotlib/stylelib/kit.mplstyle and used as follows

plt.style.use("kit")
# your standard plot

Below are three dummy plots, once with the default style and once with the kit style.

Here’s the kit.mplstyle file

### Control the fonts
mathtext.fontset : stix
font.family : sans-serif
font.serif : Tahoma
font.size : 16
axes.titlesize : 22
axes.titleweight : bold # bold title

### Control the colors
text.color:  		(0.1,0.1,0.1) # instead of black we use a more grey color
axes.labelcolor :  	(0.1,0.1,0.1)
axes.edgecolor :  	(0.1,0.1,0.1)
xtick.color:   		(0.1,0.1,0.1)
ytick.color:  		(0.1,0.1,0.1)


### Control title and margins 
axes.titlepad : 20  # move title up
axes.xmargin: 0.0   # don't add space in x direction 
axes.ymargin: 0.05 

### Control spines
axes.spines.top    : False # no bounding box right and top
axes.spines.right  : False


### Control default sizes and widths
lines.linewidth : 4
lines.markersize : 12


### Control the color cycle. These are KIT Colors
axes.prop_cycle    : cycler('color', [ (0.0, 0.5882352941176471, 0.5098039215686274),(0.0,0.0,0.0),(0.27450980392156865, 0.39215686274509803, 0.6666666666666666), (0.8745098039215686, 0.6078431372549019, 0.10588235294117647), (0.6392156862745098, 0.06274509803921569, 0.48627450980392156), (0.5490196078431373, 0.7137254901960784, 0.235294117647), (0.6352941176470588, 0.13333333333333333, 0.13725490196078433), (0.13725490196078433, 0.6313725490196078, 0.8784313725490196), (0.6549019607843137, 0.5098039215686274, 0.1803921568627451), (0.0,0.0,0.0)])


### Control the figure dimension and resolution
figure.figsize   : 10, 3.75
figure.constrained_layout.use: True
figure.dpi : 100
savefig.dpi : 200


### Control the underlying grid 
axes.grid : True
grid.color: .1
grid.linestyle: -
grid.alpha: .5
grid.linewidth: 0.1


### Control the legend box
legend.fancybox : True
legend.facecolor: white
legend.loc : upper right
legend.framealpha : 0.975
legend.edgecolor : darkgray

Update

Here’s a new version of the style file that works well with latex and sourcesanspro.

### Control the fonts
text.usetex : True
text.latex.preamble:  \usepackage{sourcesanspro}
font.family :  STIXGeneral
mathtext.fontset : stix

#font.weight : bold
font.size : 10
axes.titlesize : 10
axes.titleweight : normal # bold title

### Control the colors
text.color:  		(0.0,0.0,0.0)
axes.labelcolor :  	(0.0,0.0,0.0)
axes.edgecolor :  	(0.0,0.0,0.0)
xtick.color:   		(0.0,0.0,0.0)
ytick.color:  		(0.0,0.0,0.0)
legend.edgecolor :	(0.95,0.95,0.95)

### Control title and margins 
axes.titlepad : 10  # move title up
axes.xmargin: 0.0   # don't add space in x direction 
axes.ymargin: 0.05 
ytick.major.size : 2.0
ytick.major.width : 0.2

xtick.major.size : 2.0
xtick.major.width : 0.2


### Control default sizes and widths
lines.linewidth : 2.0
lines.markersize : 6


### Control the color cycle. These are KIT Colors
axes.prop_cycle    : cycler('color', [ (0.0, 0.5882352941176471, 0.5098039215686274), (0.0,0.0,0.0), (0.27450980392156865, 0.39215686274509803, 0.6666666666666666), (0.8745098039215686, 0.6078431372549019, 0.10588235294117647), (0.6392156862745098, 0.06274509803921569, 0.48627450980392156), (0.5490196078431373, 0.7137254901960784, 0.235294117647), (0.6352941176470588, 0.13333333333333333, 0.13725490196078433), (0.13725490196078433, 0.6313725490196078, 0.8784313725490196), (0.6549019607843137, 0.5098039215686274, 0.1803921568627451), (0.0,0.0,0.0)])


### Control the figure dimension and resolution
figure.figsize   : 5, 1.875
figure.constrained_layout.use: True
figure.dpi : 200
savefig.dpi : 400


### Control spines
axes.spines.top    : False # no bounding box right and top
axes.spines.right  : False
#axes.linewidth : 0.4

### Control the underlying grid 
axes.grid : True
grid.color: .1
grid.linestyle: -
grid.alpha: .5
grid.linewidth: 0.1


### Control the legend box
legend.framealpha : 0.975
legend.handlelength : 1.0

Resulting in