Skip to content

Commit

Permalink
refactor: Update set_plot_style to include console width parameter …
Browse files Browse the repository at this point in the history
…(only used when in VS Code)
  • Loading branch information
ma-sadeghi committed May 17, 2024
1 parent cf4ea98 commit 85595ec
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/autoeis/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

import logging
import os
import re

import arviz
Expand Down Expand Up @@ -445,7 +446,10 @@ def override_mpl_colors(override_named_colors: bool = True):


def set_plot_style(
use_arviz: bool = True, use_seaborn: bool = True, use_flexoki: bool = True
use_arviz: bool = True,
use_seaborn: bool = True,
use_flexoki: bool = True,
console_width: int = 100,
):
"""Modifies the default arviz/matplotlib config for prettier plots.
Expand All @@ -457,6 +461,9 @@ def set_plot_style(
If True, use seaborn's default plotting style. Default is True.
use_flexoki: bool, optional
If True, use Flexoki's default plotting style. Default is True.
console_width: int, optional
Width of the console in characters. Only set when in VS Code
Interactive mode, otherwise automaticall deterimined. Default is 100.
"""
# Arviz
if use_arviz:
Expand Down Expand Up @@ -495,6 +502,10 @@ def set_plot_style(
except ImportError:
pass

# Set rich console width when in VS Code Interactive Window
if os.getenv("VSCODE_PID") is not None:
rich.get_console().width = console_width


def show_nticks(ax: plt.Axes, x: bool = True, y: bool = False, n: int = 10):
"""In-place modifies Matplotlib axes to show only ``n`` ticks.
Expand Down

0 comments on commit 85595ec

Please sign in to comment.