Skip to content

Commit

Permalink
Updating for newer Tcl/Tk and matplotlib versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mcuntz committed Jan 7, 2024
1 parent 95d9530 commit 5b0f932
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
---------

v4.2 (??? 2024)
* Made ``ncvue`` work with newer matplotlib versions, updating
colormaps and using matplotlib.pyplot.style 'seaborn-v0_8-dark'.
* Made ``ncvue`` work with newer Tcl/Tk versions (ttk.Style.theme_use).

v4.1.2 (Jun 2022)
* Made ``ncvue`` a gui_script entry_point, so it can be called by
`python -m ncvue`.
Expand Down
Binary file modified src/ncvue/images/Greys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/ncvue/images/gist_gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/ncvue/images/gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/ncvue/images/plot_png_colormaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
# from matplotlib.backends.backend_pdf import PdfPages
# matplotlib.rc('ps', usedistiller='xpdf') # ps2pdf
from matplotlib import pyplot as plt
plt.style.use('seaborn-darkgrid')
try:
plt.style.use('seaborn-v0_8-darkgrid')
except OSError:
plt.style.use('seaborn-darkgrid')

if __name__ == "__main__":

Expand Down
8 changes: 6 additions & 2 deletions src/ncvue/ncvcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@
import matplotlib
# matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
# plt.style.use('seaborn-darkgrid')
plt.style.use('seaborn-dark')
try:
# plt.style.use('seaborn-v0_8-darkgrid')
plt.style.use('seaborn-v0_8-dark')
except OSError:
# plt.style.use('seaborn-darkgrid')
plt.style.use('seaborn-dark')
# plt.style.use('fast')


Expand Down
8 changes: 6 additions & 2 deletions src/ncvue/ncvmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@
import matplotlib as mpl
# mpl.use('TkAgg')
from matplotlib import pyplot as plt
# plt.style.use('seaborn-darkgrid')
plt.style.use('seaborn-dark')
try:
# plt.style.use('seaborn-v0_8-darkgrid')
plt.style.use('seaborn-v0_8-dark')
except OSError:
# plt.style.use('seaborn-darkgrid')
plt.style.use('seaborn-dark')
# plt.style.use('fast')
import cartopy.crs as ccrs

Expand Down
8 changes: 6 additions & 2 deletions src/ncvue/ncvscatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@
import matplotlib
# matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
# plt.style.use('seaborn-darkgrid')
plt.style.use('seaborn-dark')
try:
# plt.style.use('seaborn-v0_8-darkgrid')
plt.style.use('seaborn-v0_8-dark')
except OSError:
# plt.style.use('seaborn-darkgrid')
plt.style.use('seaborn-dark')
# plt.style.use('fast')


Expand Down
13 changes: 8 additions & 5 deletions src/ncvue/ncvue.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Calling routine of ncvue.
Expand Down Expand Up @@ -29,7 +29,6 @@
* Font size 13 on Windows for plots, Jun 2021, Matthias Cuntz
"""
from __future__ import absolute_import, division, print_function
import sys
import tkinter as tk
try:
Expand All @@ -43,8 +42,8 @@
import netCDF4 as nc
from .ncvmethods import analyse_netcdf
from .ncvmain import ncvMain
import matplotlib as mpl
mpl.use('TkAgg')
# import matplotlib as mpl
# mpl.use('TkAgg')
from matplotlib import pyplot as plt


Expand All @@ -65,6 +64,7 @@ def ncvue(ncfile='', miss=np.nan):
netcdf4.default_fillvals (default: np.nan).
"""
# print(mpl.get_backend())
ios = platform.system() # Windows, Darwin, Linux
if ios == 'Windows':
# make Windows aware of high resolution displays
Expand All @@ -88,7 +88,10 @@ def ncvue(ncfile='', miss=np.nan):
if ios == 'Darwin':
theme = 'aqua'
style = ttk.Style()
style.theme_use(theme)
try:
style.theme_use(theme)
except:
pass
elif ios == 'Windows':
top.option_add("*Font", "Helvetica 10")
plt.rc('font', size=13)
Expand Down

0 comments on commit 5b0f932

Please sign in to comment.