Issue
I have a text file that contain 2048 rows and 256 columns, i want to plot only 10 columns of data in an subplot,
I tried
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
data=np.loadtxt("input_data.txt")
data=data[:,0:10]
print(data.shape)
nrows=5
ncols=10
fig, axs = plt.subplots(nrows,ncols, figsize=(13,10))
count = 0
for i in range(ncols):
for j in range(nrows):
axs[i,j].plot(data[count])
count += 1
print(count)
plt.show()
But it doesnot plot the each column values, I hope experts may help me.Thanks.
Solution
I used random numbers to reproduce your problem.
data=np.random.randint(0,1,size = (2048,256))
data=data[:,0:10]
print(np.shape(data))
nrows=2
ncols=5
fig, axs = plt.subplots(nrows,ncols, figsize=(13,10))
count = 0
for i in range(nrows):
for j in range(ncols):
print(count)
axs[i,j].plot(data[:,count])
count += 1
Here is your plot.
if you put real data you will see some variation in each subplot.
Answered By - Prakhar Sharma
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.