Package: sciplotlib
sciplotlibsciplotlib is just a set of simple functions and stylesheets for more professional looking plotsThere are two main properties that make plots in papers look the way they do:default style properties such as typeface, color scheme,specific choices in terms of the placement of tick marks, or additional elements that are added to the plot such as shading or shadowsStylesheetssciplotlib aims to make (1) easier by providing stylesheets that aims to mimic the style properties found in scientific papers:We can compare the default matplotlib style with a style that mimics scatter plots found in articles from the Nature publishing group:importmatplotlib.pyplotaspltimportnumpyasnpdefmake_plot():fig,ax=plt.subplots()num_categories=10num_points=10forcategoryinnp.arange(num_categories):x=np.random.normal(size=num_points)y=np.random.normal(size=num_points)ax.scatter(x,y)returnfig,axfig,ax=make_plot()ax.set_title('Default matplotlib style')Applying the most basic style is just one line of codefromsciplotlibimportstyleasspstylewithplt.style.context(spstyle.get_style('nature-reviews')):fig,ax=make_plot()ax.set_title('Nature reviews style')Modifying figure propertiessciplotlib also aims to make (2) easier by providing functions that automically add elements found in scientific plots. For example, in many scientific journals it is common for the axis to extend only from and up to the last tick mark, and in figures found in Nature review articles, it is also common that shading will be added to plots, these are implemented by functions that simpy takes in the figure handles and return them:fromsciplotlibimportstyleasspstylefromsciplotlibimportpolishassppolishwithplt.style.context(spstyle.get_style('nature-reviews')):fig,ax=make_plot()fig,ax=sppolish.set_bounds(fig,ax)sppolish.apply_gradient(ax,extent=None,direction=0.3,cmap_range=(0.1,0),cmap='Greys')ax.set_title('Nature reviews style with bells and whistles')InstallationSimply dopip install sciplotlibAcknowledgmentssciplotlib is built on top of matplotlib. To cite matplotlib in your publications, cite:J. D. Hunter, "Matplotlib: A 2D Graphics Environment", Computing in Science & Engineering, vol. 9, no. 3, pp. 90-95, 2007Other projects that is also built on the idea of providing stylesheets / wrappers for scientific plots include:https://github.com/garrettj403/SciencePlotsColor palettes of scientific papers are obtained from the wonderfulggscilibrary:https://cran.r-project.org/web/packages/ggsci/vignettes/ggsci.htmlContributingDo contact me if you are interested in adding new functions or templates to this repository.Other fun stuffI am also including other aesthetically pleasing plot styles that are non-academic. For example, to create plots from The Economist, do:importnumpyasnpimportmatplotlib.pyplotaspltfromsciplotlibimportstyleasspstylefromsciplotlibimportmiscasspmiswithplt.style.context(spstyle.get_style('economist')):fig,ax=plt.subplots()ax.scatter(x,y)ax.text(0,1.2,'Main title',weight='bold',size=13,transform=ax.transAxes)ax.text(0,1.1,'This is the usual long subtitle',transform=ax.transAxes)fig,ax=spmisc.add_economist_rectangle(fig,ax,xloc=0.125,yloc=1.1,width=0.05,height=0.02)fig,ax=spmisc.add_datasource(fig,ax,s='Source: IMF',xloc=0.125,yloc=0,alpha=0.6)