0
import matplotlib.pyplot as plt 
import numpy as np 
ydata = [55,60,65,70,75,80] 
xdata = [1,2,3,4,5,6] 
plt.plot(xdata, ydata)  
set(plt.gca,'XTickLabel',{'Jan','Feb','Mar','April','May','June'}) 
plt.show() 

I am using matplotlib and trying to add text values to appear on the x axis.

I have tried to use the following code but get the following error message
set(plt.gca,'XTickLabel', {'Jan','Feb','Mar','April','May','June'}) TypeError: set expected at most 1 arguments, got 3 I am not sure what this is referring get current access I have set the value

1 Answers1

0

Sets are a Python data structure, it has nothing to do with what you want here, you only need to use ax.set_xticklabels and ax.set_xticks to ensure all of them show in the plot:

import matplotlib.pyplot as plt 
import numpy as np
fig, ax = plt.subplots()
ydata = [55,60,65,70,75,80] 
xdata = [1,2,3,4,5,6]
ax.set_xticks(xdata)
ax.set_xticklabels(['Jan','Feb','Mar','April','May','June'])
plt.plot(xdata, ydata)    
plt.show() 

enter image description here

Vinícius Figueiredo
  • 6,300
  • 3
  • 25
  • 44