1

I am tryiny to save my matplotlib.pyplots to a pdf. I am using PdfPages for it.

plot gets saved for :

pdf = PdfPages("Minion Plots - May 22.pdf")

fig = plt.figure()
plt.title('Counter')
plt.plot(data2['timestamp'],data2['counter'])
pdf.savefig(fig)

throws an error for

ax = plt.figure().gca()
plt.title('Time to Restart')
ax.xaxis.set_major_locator(MaxNLocator(integer=True))
plt.ylabel('Time in Minutes')
fig = plt.plot(data1['Time to Restart'])
pdf.savefig(fig)

I am using

ax = plt.figure().gca()

for 

ax.xaxis.set_major_locator(MaxNLocator(integer=True))

error is

TypeError: unhashable type: 'list' 
chink
  • 1,505
  • 3
  • 28
  • 70
  • Could you share the whole error please. Try to move `ax.xaxis.set_major_locator(MaxNLocator(integer=True))` to after `plt.plot()`. – ezatterin May 23 '19 at 09:48

1 Answers1

1
fig,ax = plt.subplots()
plt.title('Time to Restart')
ax.xaxis.set_major_locator(MaxNLocator(integer=True))
plt.ylabel('Time in Minutes')
plt.plot(data1['Time to Restart'])
pdf.savefig(fig)

this solves the issue

chink
  • 1,505
  • 3
  • 28
  • 70