Hi
I am new to pyhton. I wrote a script for time series plot with two y axis. In that script xtick vertical is not working. And I am getting only one legend out of three. Input file contains four column (Date, mean, rms, count). script is like
import numpy as np
import datetime
import matplotlib.pyplot as plt
data=np.loadtxt('file.txt',skiprows=1)
base = datetime.datetime(2018,02,14)
x = [base - datetime.timedelta(days=x) for x in range(0, 16)]
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(x,data[:,1],'r',label="mean")
ax1.plot(x,data[:,2],'b',label="rms")
ax2.plot(x,data[:,3],'g',label="count")
plt.xticks(rotation='vertical')
ax1.set_xlabel('Date',fontsize=14)
ax1.set_ylabel('Mean/ RMS', fontsize=14,color='r')
ax2.set_ylabel('count', fontsize=14,color='b')
plt.legend()
I am new to pyhton. I wrote a script for time series plot with two y axis. In that script xtick vertical is not working. And I am getting only one legend out of three. Input file contains four column (Date, mean, rms, count). script is like
import numpy as np
import datetime
import matplotlib.pyplot as plt
data=np.loadtxt('file.txt',skiprows=1)
base = datetime.datetime(2018,02,14)
x = [base - datetime.timedelta(days=x) for x in range(0, 16)]
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(x,data[:,1],'r',label="mean")
ax1.plot(x,data[:,2],'b',label="rms")
ax2.plot(x,data[:,3],'g',label="count")
plt.xticks(rotation='vertical')
ax1.set_xlabel('Date',fontsize=14)
ax1.set_ylabel('Mean/ RMS', fontsize=14,color='r')
ax2.set_ylabel('count', fontsize=14,color='b')
plt.legend()