Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotting with hypertools overwrites existing matplotlib style #243

Closed
paxtonfitzpatrick opened this issue Oct 7, 2020 · 0 comments · Fixed by #245
Closed

plotting with hypertools overwrites existing matplotlib style #243

paxtonfitzpatrick opened this issue Oct 7, 2020 · 0 comments · Fixed by #245
Assignees

Comments

@paxtonfitzpatrick
Copy link
Member

I'm not entirely sure why this happens, but calls to hypertools.plot seem to alter the style of subsequent non-hypertools plots. Example:

import numpy as np
import hypertools as hyp
import matplotlib.pyplot as plt

%matplotlib inline    # running in a notebook
geo = hyp.load('weights_avg')
plt.plot(np.arange(10))
plt.show()

Screen Shot 2020-10-06 at 8 46 27 PM

geo.plot(animate=False, legend=['first', 'second'], show=True)

Screen Shot 2020-10-06 at 8 46 51 PM

plt.plot(np.arange(10))
plt.show()

Screen Shot 2020-10-06 at 8 47 14 PM

Although I don't see this explicitly happening anywhere in the code, it appears that hypertools is updating the rcParams:

import numpy as np
import hypertools as hyp
import matplotlib.pyplot as plt
%matplotlib inline
geo = hyp.load('weights_avg')

plt.plot(np.arange(10))
plt.close()

rcparams_before = (plt.rcParams).copy()

geo.plot(animate=False, legend=['first', 'second'], show=False)
plt.close()

rcparams_after = (plt.rcParams).copy()

plt.plot(np.arange(10))
plt.close()

for k, v in rcparams_before.items():
    if v != rcparams_after[k]:
        print(f'{k}\n\tbefore: {v}\n\tafter: {rcparams_after[k]}\n')

Output:

axes.axisbelow
	before: line
	after: True

axes.edgecolor
	before: black
	after: .8

axes.grid
	before: False
	after: True

axes.labelcolor
	before: black
	after: .15

axes.prop_cycle
	before: cycler('color', ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf'])
	after: cycler('color', [(0.86, 0.3712, 0.33999999999999997), (0.33999999999999997, 0.8287999999999999, 0.86)])

figure.facecolor
	before: (1, 1, 1, 0)
	after: white

font.sans-serif
	before: ['DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', 'sans-serif']
	after: ['Arial', 'DejaVu Sans', 'Liberation Sans', 'Bitstream Vera Sans', 'sans-serif']

grid.color
	before: #b0b0b0
	after: .8

image.cmap
	before: viridis
	after: rocket

interactive
	before: True
	after: False

lines.solid_capstyle
	before: projecting
	after: round

patch.edgecolor
	before: black
	after: w

patch.facecolor
	before: C0
	after: (0.86, 0.3712, 0.33999999999999997)

patch.force_edgecolor
	before: False
	after: True

text.color
	before: black
	after: .15

xtick.bottom
	before: True
	after: False

xtick.color
	before: black
	after: .15

ytick.color
	before: black
	after: .15

ytick.left
	before: True
	after: False

I think I know how to handle this, so I'll take care of this when I fix #242 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant