d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Matplotlib Won't Show X-axis Labels In Spyder/pyth
Add Reply New Topic New Poll
Member
Posts: 13,480
Joined: May 27 2013
Gold: 74.00
Dec 29 2018 01:12pm
hey guys i've run into a problem where my plot doesn't show the X axis labels for some reason.
i'm trying to show a visualisation of a line graph but it only shows me this




===================================


Heres my simple code;

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
%matplotlib inline

data = pd.read_csv(" MY FILE IN CSV ", usecols=['Month', 'Average'], parse_dates=['Month'])
data.set_index('Month',inplace=True)

fig, ax = plt.subplots(figsize=(10,7))
data.plot(ax=ax)

ax.set_xticks(np.arange(len(x)))
ax.set_xtickslabels(x, rotation = 45)
ax.xaxis.set_major_locator(mdates.WeekdayLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b %d'))


have i done something wrong?
i based it based on this link here : https://scentellegher.github.io/programming/2017/05/24/pandas-bar-plot-with-formatted-dates.html

Member
Posts: 13,480
Joined: May 27 2013
Gold: 74.00
Dec 29 2018 08:02pm
Gg
Member
Posts: 13,480
Joined: May 27 2013
Gold: 74.00
Jan 1 2019 09:52am
Nvm i solved it using another code
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll