Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
suyashi29
GitHub Repository: suyashi29/python-su
Path: blob/master/Generative AI for Intelligent Data Handling/Day1 Data Visualization using Matplotlib.ipynb
3074 views
Kernel: Python 3 (ipykernel)
import numpy as np import pandas as pd import matplotlib.pyplot as plt # Generating sample data np.random.seed(0) data = { 'Technology': np.random.choice(['Python', 'Java', 'JavaScript', 'C++', 'Ruby'], 3000), 'Usage': np.random.randint(1, 11, 3000), 'Popularity': np.random.randint(1, 101, 3000), 'Cost': np.random.uniform(100, 1000, 3000), 'Innovation': np.random.randint(1, 6, 3000) } df = pd.DataFrame(data) # Example plots # Histogram plt.figure(figsize=(8, 6)) plt.hist(df['Usage'], bins=20, color='skyblue', edgecolor='black') plt.title('Usage Distribution') plt.xlabel('Usage') plt.ylabel('Frequency') plt.grid(True) plt.show() # Scatter plot plt.figure(figsize=(8, 6)) plt.scatter(df['Popularity'], df['Cost'], color='orange', alpha=0.5) plt.title('Popularity vs Cost') plt.xlabel('Popularity') plt.ylabel('Cost') plt.grid(True) plt.show() # Bar plot tech_counts = df['Technology'].value_counts() plt.figure(figsize=(10, 6)) plt.bar(tech_counts.index, tech_counts.values, color='green') plt.title('Technology Distribution') plt.xlabel('Technology') plt.ylabel('Count') plt.xticks(rotation=45) plt.grid(axis='y') plt.show() # Box plot plt.figure(figsize=(8, 6)) plt.boxplot(df['Innovation'], vert=False) plt.title('Innovation Distribution') plt.xlabel('Innovation') plt.grid(True) plt.show()
Image in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebook
# Line chart plt.figure(figsize=(10, 6)) tech_usage_mean = df.groupby('Technology')['Usage'].mean() plt.plot(tech_usage_mean.index, tech_usage_mean.values, marker='o', linestyle='-') plt.title('Average Usage of Technologies') plt.xlabel('Technology') plt.ylabel('Average Usage') plt.xticks(rotation=45) plt.grid(True) plt.show()
Image in a Jupyter notebook
## pip install wordcloud --trusted-host pypi.org --trusted-host files.pythonhosted.org