I have the following code. The goal is to save some graphics in pdf format in a directory that I created using os.mkdir ("...") but I get the following error:
IOError: [Errno 13] Permission denied: '\ enva1.pdf'
I do not know if the bug is python or because of security problems in my directory.
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import os
import re
os.chdir("./envolventes")
diractual = os.getcwd()
ficheros = os.listdir(diractual)
lista_limpia = [ x for x in ficheros if ("D" not in x) & (int(re.match('.*?([0-9]+).TXT', x).group(1)) <= 45)]
os.mkdir("./GRAFICAS")
for p in range(1,46):
fig=plt.figure('Aceleraciones')
plt.title('Punto ' + str(p))
for t in range(1,11): # Los 10 trenes
filename='T' + str(t) + 'A' + str(p) + '.TXT'
archivo=open(filename)
lineas=archivo.readlines()
lineas.append('0')
datos=lineas[13:415]
velocidades=[]
aceleraciones=[]
for i in datos[:]:
v=i[9:17]
velocidades.append(float(v))
a=i[31:45]
aceleraciones.append(float(a))
line,=plt.plot(velocidades,aceleraciones,label=r"A"+str(t))
plt.xlabel(r'km/h') #Etiqueta del eje x
plt.ylabel(r'm/s2') #Etiqueta del eje y
plt.legend(loc=0)
plt.show()
fig.savefig("\enva"+str(p)+".pdf")