Reputation: 181
I've been trying several style sheets but none of them seems to be applied to the canvas. This is the first time I'm using twinx()
so maybe that's the issue. The code I have tried is below -
import pickle
import numpy as np
import matplotlib.pyplot as plt
with open("acc.pkl", "rb") as a:
acc = pickle.load(a)
with open("loss.pkl", "rb") as b:
loss = pickle.load(b)
x = np.array([point for point in range(100)])
fig, graph_1 = plt.subplots()
points_1 = np.array(acc)
graph_1.plot(x, points_1, 'b')
graph_2 = graph_1.twinx()
points_2 = np.array(loss)
graph_2.plot(x, points_2, 'r')
plt.style.use('fivethirtyeight')
plt.xlabel('epochs')
fig.tight_layout()
plt.show()
Upvotes: 3
Views: 1432
Reputation: 339200
The stylesheet parameters are applied at the time the object that uses them is created.
E.g. if you want to have a figure and axes in a given style, you need to set the style sheet before creating them via plt.subplots
.
plt.style.use('fivethirtyeight')
fig, graph_1 = plt.subplots()
Upvotes: 2