Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test_wxmplot_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
max-parallel: 4
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
defaults:
run:
shell: bash -l {0}
Expand All @@ -34,7 +34,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install conda dependencies
run: |
conda install -y -c conda-forge python=${{ matrix.python-version }} "numpy>=1.23" "matplotlib>=3.8" "wxpython>=4.2" pip pytest
conda install -y -c conda-forge python=${{ matrix.python-version }} "numpy>=1.23" "matplotlib>=3.8" "wxpython>=4.2.2" pip pytest
conda info -a
conda list
- name: Install wxmplot with pip
Expand Down
9 changes: 6 additions & 3 deletions doc/plotpanel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ same meaning, as indicated by the right-most column.
+------------------+------------+---------+------------------------------------------------+-----+--------------+
| label | string | None | trace label (defaults to 'trace N') | 1 | yes |
+------------------+------------+---------+------------------------------------------------+-----+--------------+
| theme | str | '' | theme for colors and text size | 2 | no |
| theme | str | 'auto' | theme for colors and text size | 2 | no |
+------------------+------------+---------+------------------------------------------------+-----+--------------+
| color | string | blue | color to use for trace | 3 | yes |
+------------------+------------+---------+------------------------------------------------+-----+--------------+
Expand Down Expand Up @@ -187,12 +187,15 @@ same meaning, as indicated by the right-most column.
means to use the previously used value.

2. The *theme* will set the color palette and make stylistic choices. Choices include
'light' (the default), 'white-background', 'dark', 'matplotlib', 'seaborn',
'auto' (default), 'light', 'white-background', 'dark', 'matplotlib', 'seaborn',
'ggplot', 'bmh', 'fivethirtyeight', 'grayscale', 'dark_background',
'tableau-colorblind10', 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark',
'seaborn-darkgrid', 'seaborn-dark-palette', 'seaborn-deep', 'seaborn-notebook',
'seaborn-muted', 'seaborn-pastel', 'seaborn-paper', 'seaborn-poster',
'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'seaborn-whitegrid', and
'seaborn-talk', 'seaborn-ticks', 'seaborn-white', and
'seaborn-whitegrid. Note that the default 'auto' will choose
between 'light' and 'dark' based on system Dark Mode, and
automatically switch when that Dark Mode changes.

3. All *color* arguments can be a common color name ("blue", "red", "black", etc), a
standard X11 color names ("cadetblue3", "darkgreen", etc), or an RGB hex color
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ classifiers = [

dependencies = [
"wxPython>=4.2.0",
"wxutils>=0.3.3",
"wxutils>=2026.1.0",
"darkdetect",
"pyobjc-framework-Cocoa; platform_system == 'Darwin'",
"matplotlib>=3.9.0",
"pytz",
"numpy>=1.26",
Expand Down
400 changes: 12 additions & 388 deletions wxmplot/colors.py

Large diffs are not rendered by default.

51 changes: 41 additions & 10 deletions wxmplot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
from matplotlib.font_manager import FontProperties
from matplotlib import rc_params, rcParams
import matplotlib.style
from wxutils.colors import DARK_THEME
from cycler import cycler
from .colors import hexcolor, mpl2hexcolor, DARK_THEME
from .colors import hexcolor, mpl2hexcolor

SIDE_YAXES = {'left': 1, 'right': 2, 'right2': 3, 'right3': 4}

Expand Down Expand Up @@ -62,6 +63,7 @@
linecolors = ('#1f77b4', '#d62728', '#2ca02c', '#ff7f0e', '#9467bd',
'#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf')


CONFIG_SAVE = ('auto_margins', 'axes_style', 'current_theme',
'facecolor', 'framecolor', 'gridcolor',
'hidewith_legend', 'labelfont', 'legend_loc',
Expand All @@ -71,7 +73,12 @@
'scatter_selectedge', 'scatter_size', 'show_grid',
'show_legend', 'show_legend_frame', 'textcolor',
'titlefont', 'traces', 'viewpad', 'xscale', 'yscale',
'y2scale', 'y3scale', 'y4scale', 'zoom_style')
'y2scale', 'y3scale', 'y4scale', 'zoom_style',
'hist_bins', 'hist_density', 'hist_cumulative',
'hist_histtype', 'hist_orientation', 'hist_align',
'hist_stacked', 'hist_rwidth', 'bar_width',
'bar_bottom', 'bar_align', 'bar_orientation')


light_theme = {'axes.grid': True,
'axes.axisbelow': True,
Expand Down Expand Up @@ -124,7 +131,7 @@

Themes = {}

for tname in ('light', 'white-background', 'dark', 'matplotlib',
for tname in ('auto', 'light', 'white-background', 'dark', 'matplotlib',
'ggplot', 'bmh', 'fivethirtyeight', 'grayscale',
'dark_background', 'mpl_gallery', 'petroff10',
'tableau-colorblind10', 'Solarize_Light2', 'seaborn',
Expand All @@ -134,8 +141,6 @@
'seaborn-pastel', 'seaborn-paper', 'seaborn-poster',
'seaborn-talk', 'seaborn-ticks', 'seaborn-white',
'seaborn-whitegrid'):


theme = rc_params()
theme['backend'] = 'WXAgg'
if tname == 'matplotlib':
Expand Down Expand Up @@ -170,7 +175,7 @@

default_config = {'auto_margins': True,
'axes_style': 'box',
'current_theme': 'dark' if DARK_THEME else 'light',
'current_theme': 'auto', #== 'dark' if DARK_THEME else 'light'
'data_deriv': False,
'data_expr': None,
'draggable_legend': False,
Expand Down Expand Up @@ -203,7 +208,13 @@
'viewpad': 2.5,
'with_data_process': True,
'zoom_style': 'both x and y',
'labelfont': 9, 'legendfont': 7, 'titlefont': 10}
'labelfont': 9, 'legendfont': 7, 'titlefont': 10,
'hist_bins': 10, 'hist_density': False,
'hist_cumulative': False, 'hist_histtype': 'bar',
'hist_orientation': 'vertical', 'hist_align': 'mid',
'hist_stacked': False, 'hist_rwidth': None,
'bar_width': 0.8, 'bar_bottom': 0,
'bar_align': 'center', 'bar_orientation': 'vertical'}


def ifnot_none(val, default):
Expand Down Expand Up @@ -277,7 +288,7 @@ class PlotConfig:
"""Plot Configuration for Line Plots, holding most configuration data """

def __init__(self, canvas=None, panel=None, with_data_process=True,
theme=None, theme_color_callback=None,
theme='auto', theme_callback=None, theme_color_callback=None,
margin_callback=None, trace_color_callback=None,
custom_config=None):

Expand All @@ -288,10 +299,11 @@ def __init__(self, canvas=None, panel=None, with_data_process=True,
self.symbols = list(MarkerMap.keys())
self.trace_color_callback = trace_color_callback
self.theme_color_callback = theme_color_callback
self.theme_callback = theme_callback
self.margin_callback = margin_callback
self.current_theme = theme
if self.current_theme is None:
self.current_theme = 'dark' if DARK_THEME else 'light'
self.current_theme = 'auto'
self.legend_map = {}
self.legend_locs = ['best', 'upper right' , 'lower right', 'center right',
'upper left', 'lower left', 'center left',
Expand Down Expand Up @@ -352,10 +364,15 @@ def set_defaults(self):
self.set_theme()


def set_theme(self, theme=None):
def set_theme(self, theme='auto', is_dark=None):
if theme in self.themes:
self.current_theme = theme

cur_theme = self.themes[self.current_theme]
if theme in ('auto', 'None', '', None):
if is_dark is None:
is_dark = DARK_THEME
cur_theme = self.themes['dark'] if is_dark else self.themes['light']
rcParams.update(cur_theme)

self.show_grid = cur_theme['axes.grid']
Expand Down Expand Up @@ -1231,3 +1248,17 @@ def get_viewpads(self):
if cur not in o:
o.append(cur)
return [i/100.0 for i in sorted(o)]

def make_hist_kwargs(self, trace=0):
"""make keywords for axes.hist()"""
kwargs = {}

# print("make hist kwargs")
trace = self.get_trace(trace)
prop = self.traces[trace]
# print("L Trace ", prop)

for key in ('bins', 'density', 'cumulative', 'histtype',
'orientation', 'align', 'stacked', 'rwidth'):
kwargs[key] = getattr(self, f'hist_{key}')
return kwargs
28 changes: 8 additions & 20 deletions wxmplot/imageconf.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import wx
import wx.lib.colourselect as csel
import wx.lib.agw.flatnotebook as flat_nb
import wx.lib.scrolledpanel as scrolled

from math import log10

import numpy as np

import yaml

import matplotlib.cm as cmap
from matplotlib.ticker import FuncFormatter

from wxutils import get_cwd
from .colors import register_custom_colormaps, hexcolor, hex2rgb, mpl_color, GUI_COLORS
from wxutils import (get_cwd, LabeledTextCtrl, SimpleText,
Check, Choice, HLine, FloatSpin, MenuItem,
flatnotebook, get_color, set_color)

from .colors import register_custom_colormaps, hexcolor, hex2rgb, mpl_color
from .config import ifnot_none
from .plotconfigframe import autopack
from .utils import LabeledTextCtrl, SimpleText, Check, Choice, HLine, FloatSpin, MenuItem

try:
import yaml
HAS_YAML = True
except ImportError:
HAS_YAML = False

cm_names = register_custom_colormaps()

Expand Down Expand Up @@ -61,7 +59,6 @@
RGB_COLORS = ('red', 'green', 'blue')

labstyle = wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL
FNB_STYLE = flat_nb.FNB_NO_X_BUTTON|flat_nb.FNB_SMART_TABS|flat_nb.FNB_NO_NAV_BUTTONS|flat_nb.FNB_NODRAG

class ImageConfig:
def __init__(self, axes=None, fig=None, canvas=None):
Expand Down Expand Up @@ -409,8 +406,6 @@ def __init__(self, parent=None, config=None, trace_color_callback=None):
self.SetMenuBar(mbar)

def save_config(self, evt=None, fname='wxmplot.yaml'):
if not HAS_YAML:
return
file_choices = 'YAML Config File (*.yaml)|*.yaml'
dlg = wx.FileDialog(self, message='Save image configuration',
defaultDir=get_cwd(),
Expand All @@ -426,8 +421,6 @@ def save_config(self, evt=None, fname='wxmplot.yaml'):


def load_config(self, evt=None):
if not HAS_YAML:
return
file_choices = 'YAML Config File (*.yaml)|*.yaml'
dlg = wx.FileDialog(self, message='Read image configuration',
defaultDir=get_cwd(),
Expand Down Expand Up @@ -704,12 +697,7 @@ def DrawPanel(self):
font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.SetFont(font)

self.nb = flat_nb.FlatNotebook(self, wx.ID_ANY, agwStyle=FNB_STYLE)
self.nb.SetTabAreaColour(GUI_COLORS.nb_area)
self.nb.SetActiveTabColour(GUI_COLORS.nb_active)
self.nb.SetNonActiveTabTextColour(GUI_COLORS.nb_text)
self.nb.SetActiveTabTextColour(GUI_COLORS.nb_activetext)

self.nb = flatnotebook(self, with_nav_buttons=True, with_smart_tabs=True)
self.nb.AddPage(self.make_contour_panel(parent=self.nb, font=font),
'Contours', True)

Expand Down
4 changes: 2 additions & 2 deletions wxmplot/imagepanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .basepanel import BasePanel
from .utils import inside_poly, MenuItem
from .plotframe import PlotFrame
from .colors import GUI_COLORS, wxcol2hex
from .colors import wxcol2hex, get_color

class ImagePanel(BasePanel):
"""
Expand Down Expand Up @@ -345,7 +345,7 @@ def BuildPanel(self):
self.fig = Figure(figsize, dpi=self.dpi)
self.gridspec = GridSpec(1,1)
self.axes = self.fig.add_subplot(self.gridspec[0],
facecolor=wxcol2hex(GUI_COLORS.text_bg))
facecolor=wxcol2hex(get_color('text_bg')))
self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
self.canvas.gui_repaint = self.gui_repaint
self.conf.axes = self.axes
Expand Down
2 changes: 1 addition & 1 deletion wxmplot/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def get_image_window(win=1, size=None, wintitle=None):

return display

def plot(x,y=None, win=1, new=False, size=None, wintitle=None, theme=None, **kws):
def plot(x,y=None, win=1, new=False, size=None, wintitle=None, theme='auto', **kws):
"""plot(x, y, win=1, new=False, ...)

Plot trace of x, y arrays in a PlotFrame
Expand Down
Loading
Loading