Understanding Graphing in Python (for Statements)

Asked 2 years ago, Updated 2 years ago, 30 views

I would like to create multiple dataFrames (22) as shown in the link below, and then have them write a graph.

Multiple txt Phas in a Folder in PythonI want to load files all at once and store them in dataFrame

I would like to create a graph in the diagram below, and I would like to read dataFrame continuously in for statements and so on.

Enter a description of the image here

If there is a dataFrame without data at that time, how would you handle dataFrame without data to skip the dataFrame without data to prevent it from being written (to avoid errors) and have it written by continuous processing such as for statements?

python python3

2022-09-29 21:35

1 Answers

The following are matplotlib.figure.Figure.add_subplot and matplotlib.pyplot.tight_layout.Data frames are randomly created.

import numpy as np
import pandas aspd
import matplotlib.pyplot asplt

w,h = 5,5
config=plt.figure()
for n in range (1, w*h+1):
  df = pd.DataFrame({
    'x': np.linspace(0,1.0,11), 'y': np.random.rand(11),
  })
  ax=fig.add_subplot(w,h,n)
  ax.plot(df['x'], df['y'])
  ax.set_xticks(np.linspace(0,1.0,2))
  ax.set_yticks(np.linspace(0,1.0,2))

plt.ight_layout()
plt.show()

example


2022-09-29 21:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.