import logging

import matplotlib.pyplot as plt

from zyplib._config import config

from . import plot_common
from .mpl_utils import (
    MplStyleContext,
    color_cycle_context,
    draw_annotate_arrow,
    draw_comparison_lines,
    draw_error_regions,
    draw_highlight,
    draw_inset_zoom,
    draw_reference_lines,
    draw_text,
    get_current_color_cycle,
    make_figure_layout,
    make_grids,
    register_mpl_styles,
    sample_color_list,
    save_figure,
    set_scientific_formatter,
    style_ax,
    style_figure,
    use_color_cycle,
    use_font_family,
)
from .plot_common import (
    plot_area,
    plot_bar,
    plot_box,
    plot_distribution,
    plot_dual_line,
    plot_heatmap,
    plot_kde,
    plot_line,
    plot_radar,
    plot_scatter,
)
from .plot_eeg import plot_pwelch, plot_signals, plot_stft
from .plot_misc import plot_group_divide
from .plot_ml import (
    plot_classification_report,
    plot_confusion_matrix,
    plot_feature_importance,
    plot_pca,
    plot_precision_recall_curve,
    plot_roc_curve,
    plot_training_curve,
    plot_tsne,
)
from .topomap import pxx_topomap, topmap

__all__ = [
    'plot_signals',
    'plot_stft',
    'plot_pwelch',
    'plot_common',
    'plot_group_divide',
    'register_mpl_styles',
    'topmap',
    'pxx_topomap',
    'plot_line',
    'plot_dual_line',
    'plot_bar',
    'plot_scatter',
    'plot_distribution',
    'plot_box',
    'plot_area',
    'plot_radar',
    'plot_heatmap',
    'plot_pca',
    'plot_tsne',
    'plot_confusion_matrix',
    'plot_classification_report',
    'plot_feature_importance',
    'plot_training_curve',
    'plot_roc_curve',
    # mpl_utils
    'make_figure_layout',
    'make_grids',
    'save_figure',
    'MplStyleContext',
    'use_font_family',
    'use_color_cycle',
    'get_current_color_cycle',
    'color_cycle_context',
    'sample_color_list',
    'style_ax',
    'style_figure',
    'draw_annotate_arrow',
    'draw_comparison_lines',
    'draw_error_regions',
    'draw_highlight',
    'draw_inset_zoom',
    'draw_reference_lines',
    'draw_text',
    'set_scientific_formatter',
    # plot_ml
    'plot_roc_curve',
    'plot_precision_recall_curve',
    'plot_training_curve',
    'plot_classification_report',
    'plot_feature_importance',
    'plot_confusion_matrix',
    'plot_tsne',
    'plot_pca',
]

logger = logging.getLogger(__name__)


if config.LOAD_DEFAULT_MPL_STYLE:
    from .mpl_utils.style import register_mpl_styles

    styles = register_mpl_styles()
    if 'zyp-default' in styles:
        plt.style.use('zyp-default')
        logger.debug('Matplotlib 加载 zyplib 默认样式')
