dunovank / jupyter-themes

Custom Jupyter Notebook Themes
MIT License
9.74k stars 1.06k forks source link

matplotlib ticks not plotting using jupyterthemes #407

Closed pythonic2020 closed 3 years ago

pythonic2020 commented 3 years ago

Using this setup:

jt -t onedork -fs 95 -tfs 11 -nfs 115 -cellw 88% -T -N -kl -cursc o -cursw 2 -f roboto

from jupyterthemes import jtplot
jtplot.style(theme='onedork', context='notebook', fscale=1.4, gridlines='--')

plot axis ticks are not showing on matplotlib plots, either major or minor ticks. Is anyone else seeing this? It makes no difference if I remove the context, fscale, or gridlines params from the jtplot.style() call. The above applies to onedork and solarizedd themes.

The ticks show normally using matplotlib styles (e.g. ggplot).

Untitled

ggplot in notebook:

Untitled2

The issue can be checked using this matplotlib code from

Major and minor ticks

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,
                               AutoMinorLocator)

t = np.arange(0.0, 100.0, 0.1)
s = np.sin(0.1 * np.pi * t) * np.exp(-t * 0.01)

fig, ax = plt.subplots()
ax.plot(t, s)

# Make a plot with major ticks that are multiples of 20 and minor ticks that
# are multiples of 5.  Label major ticks with '%d' formatting but don't label
# minor ticks.
ax.xaxis.set_major_locator(MultipleLocator(20))
ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))

# For the minor ticks, use no labels; default NullFormatter.
ax.xaxis.set_minor_locator(MultipleLocator(5))

plt.show()

Untitled


pd.show_versions():

INSTALLED VERSIONS

commit : f2ca0a2665b2d169c97de87b8e778dbed86aea07 python : 3.7.8.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19041 machine : AMD64 processor : Intel64 Family 6 Model 26 Stepping 4, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : None.None

pandas : 1.1.1 numpy : 1.19.1 pytz : 2020.1 dateutil : 2.8.1 pip : 20.2.2 setuptools : 49.6.0.post20200814 Cython : None pytest : None hypothesis : None sphinx : 3.2.1 blosc : None feather : None xlsxwriter : None lxml.etree : 4.5.2 html5lib : None pymysql : None psycopg2 : None jinja2 : 2.11.2 IPython : 7.18.1 pandas_datareader: None bs4 : 4.9.1 bottleneck : None fsspec : None fastparquet : None gcsfs : None matplotlib : 3.3.1 numexpr : 2.7.1 odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pytables : None pyxlsb : None s3fs : None scipy : 1.5.2 sqlalchemy : 1.3.19 tables : 3.6.1 tabulate : None xarray : None xlrd : 1.2.0 xlwt : None numba : None

pythonic2020 commented 3 years ago

These matplotlib commands will show the ticks,

ax.tick_params(length=4, which='major')
ax.tick_params(length=2, which='minor')

but I just found that jtplot.style(ticks=True) must be used to show ticks. Strange that the default behavior is not to show ticks. So, never mind.