Как создать несколько графиков в цикле Python?Python

Программы на Python
Гость
Как создать несколько графиков в цикле Python?

Сообщение Гость »


I have following table where we have columns topic, score1, score2, score3, score4.

Код: Выделить всё

| id | score1 | score2  | score3   | score4  | |----|--------|---------|----------|---------| | 1  | 0.05   | 0.0608  | 0.476464 | 0.53535 | | 1  | 0.08   | 0.0333  | 0.8263   | 0.9463  | | 1  | 0.05   | 0.0926  | 0.8694   | 0.9903  | | 2  | 0.08   | 0.0425  | 0.1948   | 0.3958  | | 2  | 0.09   | 0.0992  | 0.1238   | 0.1937  | | 4  | 0.1    | 0.0627  | 0.0738   | 0.0987  | | 4  | 0.05   | 0.06262 | 0.721    | 0.12    | | 4  | 0.04   | 0.05227 | 0.0825   | 0.283   | | 4  | 0.02   | 0.04728 | 0.0628   | 0.0936  | 
I want to create a plot for each id. The plot should show the count of ids in 4 scores. I want to create multiple plots for each id (here separate plots for id 1, 2 and 4).

Here is what I tried till now.

Using sql I created separate column for score classifying each score and used below python code for plotting. Here I was only able to generate single plot.

Код: Выделить всё

plt.figure(figsize=(10, 6)) sns.countplot(x='score', data=df1) plt.xlabel('Score') plt.xticks(rotation=90) plt.ylabel('Count') plt.title('Distribution per score - id 1') plt.show() 
Is there any easier way where we can do all this only in python and plot multiple plots?


Источник: https://stackoverflow.com/questions/781 ... on-in-loop

Вернуться в «Python»