I'm trying to learn how to make graphics in Python. I did one now and it was not very good:
AlldatesareonApril10,2017,onlycomingfrom07:50a.m.to08:40p.m.(GMT-3h)Inthefigure,itappeareduntilthedatetodayand,asaresult,thepointsdisappeared.Onthetimeaxis(Xaxis)wastoappearonlythedateofApril10,2017withthevariationofhour,minuteandsecond!ThisistheproblemHowtofix?
importmatplotlib.pyplotaspltimportmatplotlib.datesasdatesfromdatetimeimportdatetime,timedeltax=[]y=[]dataset=open("dataset_semAtaques.csv","r") ##separacao no csv eh por virgulas
for line in dataset:
line = line.strip() #23,24\n -> 23,24 retira a quebra de linha
X,Y = line.split(",") #separador eh a virgula
x.append( float(X))
y.append(float (Y))
dataset.close()
x1 = [datetime.fromtimestamp(int(d)) for d in x]
plt.gca().xaxis.set_major_formatter(dates.DateFormatter('%m/%d/%Y %H:%M:%S'))
plt.plot(x1, y, 'ro')
plt.title("Gráfico do número de Conexões por segundo antes do Ataque")
plt.ylabel("Numero de conexões por segundo")
plt.xlabel('Tempo')
plt.gcf().autofmt_xdate()
plt.show()
The dataset_semAccounts.csv file looks like this:
1491821400,0
1491821580,0
1491821760,0
1491821940,0
1491822120,3
1491822300,3
1491822480,2
1491822660,2
1496012764,3
1491823020,2
1491823200,2
1491823380,2
1491823560,3
1491823740,2
1491823920,2
1491824100,2
1491824280,3
1491824400,2