Package: pyplot-themes
pyplot-themesThemes you can see that apply to matplotlib, seaborn, and pandas plots.This package was inspired by theggthemespackage in R,
and the code influenced from theseabornpackage in python(specificallyrcmod.py).InstallingInstall from PyPIpip install pyplot-themesOr directly from GitHubpip install git+https://github.com/raybuhr/pyplot-themes.gitUsageEnvironmentimportsyssys.version'3.7.1 (default, Dec 14 2018, 19:28:38) \n[GCC 7.3.0]'importmatplotlib.pyplotaspltfromseabornimportpalplot# only used to show off palettesfromstringimportascii_uppercaseimportnumpyasnpdefexample_scatter_plot(num_cats=6):foriinrange(num_cats):cat=ascii_uppercase[i]x=np.random.random(100)y=np.random.random(100)+iplt.scatter(x,y,marker='o',label=cat)plt.legend(loc='best')defexample_bar_plot(num_cats=6):bar_width=1/num_cats+1foriinrange(num_cats):cat=ascii_uppercase[i]x=np.arange(11)+5*iy=np.array([0,1,2,3,4,5,4,3,2,1,0])+np.random.random(1)plt.bar(x,y,label=cat,width=bar_width)plt.legend(loc='best')defexample_plots(num_cats=6):example_scatter_plot(num_cats)plt.show()example_bar_plot(num_cats)plt.show()Default Maplotlib Themeexample_plots()As you can see, the default theme has good contrast in colors, but leaves a bit to be desired in the sige of the chart (i.e. figure size aka figsize) and font.Usageimportpyplot_themesasthemesthemes.__version__'0.2.0'themes.theme_minimal()This updates the global theme settings for matplotlib with a nice minimal style using colorblind safe colors.palplot(themes.palettes.Colorblind.colors)example_plots()As you can see, our plots are much larger now, have accessible colors, and have some light gridlines to make identifying values a bit easier.There are a few parameters available in all themes:grid: toggles grid lines on/offticks: toggles tick marks on/offfigsize: sets the default size of plots (you can still change each plot in an ad hoc manner if needed)fontsize: sets the default font size to be usedSome themes will allow you to pass in whatever colors you want, others you have to pick a color scheme from available options, some only let you reverse the order of the default color palette, and some don't let you mess with the colors at all. Experiment and find out what you like.themes.theme_minimal(grid=False,ticks=False,fontsize=18)example_scatter_plot()plt.title("Look Mom, no lines!")Text(0.5, 1.0, 'Look Mom, no lines!')Themesthemes.theme_dark()example_plots()themes.theme_tableau()example_plots()palplot(themes.palettes.Solarized.dark)themes.theme_solarized(scheme="dark")example_plots()palplot(themes.palettes.Solarized.light)themes.theme_solarized(scheme="light")example_plots()palplot(themes.palettes.PaulTolColorSchemes.colors)themes.theme_paul_tol()example_plots(12)themes.theme_paul_tol(reverse_colors=True,grid=False)example_plots(num_cats=12)palplot(themes.palettes.Few.light)palplot(themes.palettes.Few.medium)palplot(themes.palettes.Few.dark)themes.theme_few(scheme="light")example_plots()themes.theme_few(scheme="medium",figsize=[5,5])example_scatter_plot()themes.theme_few(scheme="dark")example_bar_plot()themes.theme_ucberkeley(figsize=[10,5])example_plots(num_cats=4)themes.theme_ucberkeley(scheme="all",figsize=[12,6])example_plots(num_cats=16)Themes that come with matplotlibThese next themes actually come with matplotlib and you can use them without thepyplot-themespackage.
The functions here are basically thin wrappers for calling the matplotlib defined styles, but use a bigger figsize by default.themes.theme_fivethirtyeight()example_plots()themes.theme_ggplot2(figsize=[10,5])example_plots()bmhstands for Bayesian Methods for Hackersthemes.theme_bmh()example_scatter_plot()So we also have an alias for the spelled out version to make it easier to discoverthemes.theme_bayesian_methods_for_hackers()example_bar_plot()While this package provides light and dark solarized themes,matplotlibcomes with a light version as well. This one is a good choice if you want to keep more contrast in the colors of your plots.themes.theme_solarized_light2()example_plots()Modifying ThemesIn addition to making it easy to find and call the matplotlib themes,pyplot-themesalso makes it easier to modify them slightly. For example say you want to use theggplot2theme, but you want to use the Paul Tol Color Schemes palette with it.themes.theme_ggplot2(palette=themes.palettes.PaulTolColorSchemes.colors,figsize=[12,6])example_bar_plot(num_cats=12)Or maybe thefivethirtyeightcolorsthemes.theme_ggplot2(palette=themes.palettes.FiveThirtyEight.colors)example_bar_plot()Resetting to back to matplotlib defaultsOf course, sometimes when you are trying out different themes, you may find you modified a setting that you didn't quite like, but aren't sure what changed. To aid in debugging, we created a function to reset the theme back to what matplotlib starts with. Of course, you may just like the matplotlib defaults and that's ok.Note: The default settings for matplotlib can be slightly different depending on if you are using in python files (e.g. scripts) vs. in jupyter notebooks using%matplotlib inline. The reset function assumes you are using a notebook by default, but provides a parameter to toggle that off if you are not:themes.theme_reset(notebook=False)themes.theme_reset()# could also use the alias `themes.theme_matplotlib_default()`example_bar_plot()PalettesIn addition to the themes above, there are a bunch of color palettes provided. Here are a few to show off.palplot(themes.palettes.Autumn1.colors)palplot(themes.palettes.Autumn2.colors)palplot(themes.palettes.Canyon.colors)palplot(themes.palettes.Chili.colors)palplot(themes.palettes.Tomato.colors)palplot(themes.palettes.Few.medium)palplot(themes.palettes.FiveThirtyEight.colors)palplot(themes.palettes.Solarized.light)palplot(themes.palettes.Solarized.dark)palplot(themes.palettes.UCBerkeley.primary_colors)palplot(themes.palettes.UCBerkeley.secondary_colors)Sequential Palettespalplot(themes.palettes.Sequential.blues)palplot(themes.palettes.Sequential.cyans)palplot(themes.palettes.Sequential.purples)palplot(themes.palettes.Sequential.greens)palplot(themes.palettes.Sequential.oranges)palplot(themes.palettes.Sequential.reds)Diverging Palettespalplot(themes.palettes.Diverging.blueorange)palplot(themes.palettes.Diverging.orangeblue)palplot(themes.palettes.Diverging.bluepurple)palplot(themes.palettes.Diverging.purpleblue)palplot(themes.palettes.Diverging.bluered)palplot(themes.palettes.Diverging.redblue)palplot(themes.palettes.Diverging.greenpurple)palplot(themes.palettes.Diverging.purplegreen)palplot(themes.palettes.Diverging.greenred)palplot(themes.palettes.Diverging.redgreen)Using with Pandasimportpandasaspd# some made up datesales=np.random.randint(low=10,high=20,size=30)*[i**2foriinrange(1,31)]revenue=np.random.random(30)*salesmonths=pd.date_range(start="2010-01-01",periods=30,freq="M")df=pd.DataFrame({"sales":sales,"revenue":revenue.round(2)},index=months)df.head()<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>salesrevenue2010-01-31122.762010-02-285245.052010-03-319011.802010-04-30208203.932010-05-31475337.08themes.theme_minimal()df.plot()<matplotlib.axes._subplots.AxesSubplot at 0x7fdc5285f2b0>themes.theme_dark(palette=themes.palettes.Autumn1.colors)df.plot()<matplotlib.axes._subplots.AxesSubplot at 0x7fdc5297e668>ContributingThere are multiple ways you can help out with this project:submit a bug reportsubmit a feature requestFork this git repo, change some code, and submit a Pull Requestadding documentation or examples counts as changing code