varshitha22 commited on
Commit
3e2ed19
·
verified ·
1 Parent(s): 887a797

Update pages/EDA.py

Browse files
Files changed (1) hide show
  1. pages/EDA.py +15 -15
pages/EDA.py CHANGED
@@ -141,11 +141,11 @@ st.subheader("Proportion of Crops")
141
  crop_counts = df['Crop'].value_counts()
142
  explode = [0.1 if i == 0 else 0 for i in range(len(crop_counts))]
143
 
144
- fig, ax = plt.subplots(figsize=(4, 2)) # Reduced plot size
145
  ax.pie(
146
  crop_counts, labels=crop_counts.index, autopct='%1.1f%%',
147
- startangle=140, explode=explode, colors=sns.color_palette("rainbow", len(crop_counts)),
148
- textprops={'fontsize': 3} # Decreased label size
149
  )
150
  ax.set_title("Proportion of Crops", fontsize=3)
151
  st.pyplot(fig)
@@ -161,13 +161,13 @@ avg_potassium = df['Potassium'].mean()
161
  # Function to plot bar charts
162
  def plot_nutrient_crops(data, title):
163
  crop_counts = data.value_counts()
164
- fig, ax = plt.subplots(figsize=(5, 2)) # Adjusted plot size for better display
165
  crop_counts.plot(kind='bar', color='skyblue', ax=ax)
166
- ax.set_xlabel('Crops', fontsize=7)
167
- ax.set_ylabel('Count', fontsize=7)
168
- ax.set_title(title, fontsize=7)
169
- ax.tick_params(axis='x', labelsize=7) # Adjust x-axis label size
170
- ax.tick_params(axis='y', labelsize=7) # Adjust y-axis label size
171
  st.pyplot(fig)
172
 
173
  # Plot: Crops in Nutrient-Rich Soil
@@ -284,13 +284,13 @@ avg_Rainfall = df['Rainfall'].mean()
284
  # Function to plot bar charts
285
  def plot_climate_crops(data, title):
286
  clim_crop_counts = data.value_counts()
287
- fig, ax = plt.subplots(figsize=(5, 2)) # Adjusted plot size for better display
288
  clim_crop_counts.plot(kind='bar', color='skyblue', ax=ax)
289
- ax.set_xlabel('Crops', fontsize=8)
290
- ax.set_ylabel('Count', fontsize=8)
291
- ax.set_title(title, fontsize=8)
292
- ax.tick_params(axis='x', labelsize=8) # Adjust x-axis label size
293
- ax.tick_params(axis='y', labelsize=8) # Adjust y-axis label size
294
  st.pyplot(fig)
295
 
296
  # Plot: Crops in climate factors
 
141
  crop_counts = df['Crop'].value_counts()
142
  explode = [0.1 if i == 0 else 0 for i in range(len(crop_counts))]
143
 
144
+ fig, ax = plt.subplots(figsize=(2, 1)) # Reduced plot size
145
  ax.pie(
146
  crop_counts, labels=crop_counts.index, autopct='%1.1f%%',
147
+ startangle=100, explode=explode, colors=sns.color_palette("rainbow", len(crop_counts)),
148
+ textprops={'fontsize': 0.5} # Decreased label size
149
  )
150
  ax.set_title("Proportion of Crops", fontsize=3)
151
  st.pyplot(fig)
 
161
  # Function to plot bar charts
162
  def plot_nutrient_crops(data, title):
163
  crop_counts = data.value_counts()
164
+ fig, ax = plt.subplots(figsize=(4, 2)) # Adjusted plot size for better display
165
  crop_counts.plot(kind='bar', color='skyblue', ax=ax)
166
+ ax.set_xlabel('Crops', fontsize=6)
167
+ ax.set_ylabel('Count', fontsize=6)
168
+ ax.set_title(title, fontsize=6)
169
+ ax.tick_params(axis='x', labelsize=6) # Adjust x-axis label size
170
+ ax.tick_params(axis='y', labelsize=6) # Adjust y-axis label size
171
  st.pyplot(fig)
172
 
173
  # Plot: Crops in Nutrient-Rich Soil
 
284
  # Function to plot bar charts
285
  def plot_climate_crops(data, title):
286
  clim_crop_counts = data.value_counts()
287
+ fig, ax = plt.subplots(figsize=(4, 2)) # Adjusted plot size for better display
288
  clim_crop_counts.plot(kind='bar', color='skyblue', ax=ax)
289
+ ax.set_xlabel('Crops', fontsize=6)
290
+ ax.set_ylabel('Count', fontsize=6)
291
+ ax.set_title(title, fontsize=6)
292
+ ax.tick_params(axis='x', labelsize=6) # Adjust x-axis label size
293
+ ax.tick_params(axis='y', labelsize=6) # Adjust y-axis label size
294
  st.pyplot(fig)
295
 
296
  # Plot: Crops in climate factors