Beispiel #1
0
def theme_paul_tol(reverse_colors=False,
                   grid=True,
                   ticks=True,
                   figsize=None,
                   fontsize=None):
    """Theme based on the defaults in Tableau
    Parameters
    ----------
    reverse : bool, False
        Toggle color palette order forward or reverse
    grid : bool, True
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    if figsize is None:
        figsize = [12.0, 8.0]
    pal_colors = palettes.PaulTolColorSchemes.colors
    if reverse_colors:
        pal_colors = pal_colors[::-1]
    style = rcmod.theme_style(None, pal_colors, grid, ticks, figsize)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #2
0
def theme_dark(palette=None,
               grid=True,
               ticks=True,
               figsize=None,
               fontsize=None):
    """A decent, minimal dark theme
    Parameters
    ----------
    palette : list, None
        A list of hex values to pass in as a color palette
    grid : bool, True
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    if figsize is None:
        figsize = [12.0, 8.0]
    style = rcmod.theme_style(None, palette, grid, ticks, figsize)
    dark_style = rcmod.dark_settings()
    if palette is None:
        darkcolorblind = [v for v in palettes.Colorblind.colors][1:]
        dark_style.update({"axes.prop_cycle": create_palette(darkcolorblind)})
    style.update(dark_style)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #3
0
def theme_minimal(palette=None,
                  grid=True,
                  ticks=True,
                  figsize=None,
                  fontsize=None):
    """A decent, minimal theme
    Parameters
    ----------
    palette : list, None
        A list of hex values to pass in as a color palette
    grid : bool, True
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    if figsize is None:
        figsize = [12.0, 8.0]
    style = rcmod.theme_style(None, palette, grid, ticks, figsize)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #4
0
def theme_ucberkeley(scheme="primary",
                     grid=False,
                     ticks=True,
                     figsize=None,
                     fontsize=None):
    """Theme based on the brand guidelines of Univeristy of California, Berkeley.
    https://brand.berkeley.edu/

    If you want to use the theme's default font, Open Sans, you may need to 
    download and install it from: https://www.fontsquirrel.com/fonts/open-sans

    Parameters
    ----------
    scheme : str, primary, secondary or all
        Use one of primary, secondary, or all colors in the UC Berkeley palette
    grid : bool, False
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    if figsize is None:
        figsize = [12.0, 8.0]
    if scheme == "primary":
        pal_colors = palettes.UCBerkeley.primary_colors
    elif scheme == "secondary":
        pal_colors = palettes.UCBerkeley.secondary_colors
    elif scheme == "all":
        pal_colors = palettes.UCBerkeley.colors
    else:
        print(
            "UCBerkeley color scheme must be one of primary, secondary, or all."
        )
        raise
    ucb_style = {
        "grid.color": "#EEEEEE",
        "figure.facecolor": "#FFFFFF",
        "text.color": "#003262",
        "axes.labelcolor": "#003262",
        "xtick.color": "#888888",
        "ytick.color": "#888888",
        "axes.edgecolor": "#EEEEEE",
        "axes.spines.left": True,
        "axes.spines.bottom": True,
        "axes.spines.right": False,
        "axes.spines.top": False,
        "font.family": ["sans-serif"],
        "font.sans-serif": ["Open Sans", "DejaVu Sans", "sans-serif"],
        "axes.facecolor": "white",
    }
    style = rcmod.theme_style(ucb_style, pal_colors, grid, ticks, figsize)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #5
0
def theme_matplotlib_default(notebook=True):
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
        default_rcparams = {k: v for k, v in plt.rcParamsDefault.items()}
        notebook_settings = {
            "figure.dpi": 72.0,
            "figure.edgecolor": (1, 1, 1, 0),
            "figure.facecolor": (1, 1, 1, 0),
            "figure.figsize": [6.0, 4.0],
            "figure.subplot.bottom": 0.125,
            "interactive": True,
        }
        if notebook:
            default_rcparams.update(notebook_settings)
        rcmod.set_style(default_rcparams)
Beispiel #6
0
def theme_solarized(scheme="dark",
                    grid=True,
                    ticks=True,
                    figsize=None,
                    fontsize=None):
    """Theme based on the defaults in Tableau
    Parameters
    ----------
    scheme : str, dark or light
        Use one of dark or light solarized color schemes
    grid : bool, True
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    if figsize is None:
        figsize = [12.0, 8.0]
    if scheme == "dark":
        # want colors to show up, so use opposite
        solarized_colors = palettes.Solarized.light
        fig_color = solarized_colors[-1]
        ax_color = solarized_colors[-2]
        pal_colors = solarized_colors[:-2]
    elif scheme == "light":
        # want colors to show up, so use opposite
        solarized_colors = palettes.Solarized.dark
        fig_color = solarized_colors[-1]
        ax_color = solarized_colors[-2]
        pal_colors = solarized_colors[:-2]
    else:
        print("Scheme must be one of dark or light")
        raise
    style = rcmod.theme_style(None, pal_colors, grid, ticks, figsize)
    style.update({
        "figure.facecolor": fig_color,
        "axes.facecolor": fig_color,
        "axes.labelcolor": ax_color,
    })
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #7
0
def theme_solarized_light2(grid=None, ticks=None, figsize=None, fontsize=None):
    """Use the matplotlib Solarize_Light2 style
    Parameters
    ----------
    grid : bool, True
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    sl_style = _get_mpl_style_params("Solarize_Light2")
    style = rcmod.theme_style(sl_style, None, grid, ticks, figsize)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #8
0
def theme_tableau(grid=True, ticks=True, figsize=None, fontsize=None):
    """Theme based on the defaults in Tableau
    Parameters
    ----------
    grid : bool, True
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    if figsize is None:
        figsize = [12.0, 8.0]
    tableau_colors = [v for v in colors.TABLEAU_COLORS.values()]
    style = rcmod.theme_style(None, tableau_colors, grid, ticks, figsize)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #9
0
def theme_few(scheme="medium",
              grid=False,
              ticks=True,
              figsize=None,
              fontsize=None):
    """Theme based on the ideas of Stephen Few
    Parameters
    ----------
    scheme : str, medium, or dark or light
        Use one of dark or light solarized color schemes
    grid : bool, False
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    if figsize is None:
        figsize = [12.0, 8.0]
    if scheme == "medium":
        pal_colors = palettes.Few.medium
    elif scheme == "light":
        pal_colors = palettes.Few.light
    elif scheme == "dark":
        pal_colors = palettes.Few.dark
    else:
        print("Few color scheme must be one of medium, light, or dark.")
        raise
    few_style = {
        "text.color": "black",
        "axes.labelcolor": "black",
        "xtick.color": "black",
        "ytick.color": "black",
    }
    style = rcmod.theme_style(few_style, pal_colors, grid, ticks, figsize)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)
Beispiel #10
0
def theme_ggplot2(palette=None,
                  grid=None,
                  ticks=None,
                  figsize=None,
                  fontsize=None):
    """Use the matplotlib ggplot style
    Parameters
    ----------
    palette : list, None
        A list of hex values to pass in as a color palette
    grid : bool, True
        Toggle gridlines on/off
    axes : bool, True
        Toggle tick marks on/off
    figsize : list or tuple, None
        Sets the figsize for plots, for example ``figsize=[9,6]``
    fontsize : int or float, None
        Sets the font size for plots, for example ``fontsize=12.5``
    """
    ggplot_style = _get_mpl_style_params("ggplot")
    style = rcmod.theme_style(ggplot_style, palette, grid, ticks, figsize)
    if fontsize is not None:
        style.update({"font.size": fontsize})
    rcmod.set_style(style)