0% found this document useful (0 votes)
2 views4 pages

Visualization

The document outlines a Python script that analyzes IoT sensor data using pandas and matplotlib. It includes various visualizations such as line charts for temperature and humidity over time, scatter plots for light intensity versus temperature, histograms for temperature distribution, pie charts for motion detection events, and a correlation heatmap for sensor variables. The script reads a CSV file, processes the data, and generates these visualizations to provide insights into the sensor readings.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Visualization

The document outlines a Python script that analyzes IoT sensor data using pandas and matplotlib. It includes various visualizations such as line charts for temperature and humidity over time, scatter plots for light intensity versus temperature, histograms for temperature distribution, pie charts for motion detection events, and a correlation heatmap for sensor variables. The script reads a CSV file, processes the data, and generates these visualizations to provide insights into the sensor readings.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import pandas as pd

import [Link] as plt

# Read the sensor dataset


df = pd.read_csv("sensor_data.csv")

# Show first few rows


print("\n Sample IoT Sensor Data:\n")
print([Link]())

# Convert Timestamp column to datetime for better plotting


df['Timestamp'] = pd.to_datetime(df['Timestamp'])

# Line Chart — Temperature & Humidity Over Time


[Link](figsize=(10, 5))
[Link](df['Timestamp'], df['Temperature(°C)'], label='Temperature (°C)', color='red')
[Link](df['Timestamp'], df['Humidity(%)'], label='Humidity (%)', color='blue')
[Link]("Temperature and Humidity Over Time")
[Link]("Timestamp")
[Link]("Sensor Reading")
[Link]()
[Link](rotation=45)
plt.tight_layout()
[Link]()

# Scatter Plot — Light Intensity vs Temperature


[Link]()
[Link](df['LightIntensity(Lux)'], df['Temperature(°C)'], color='green')
[Link]("Light Intensity vs Temperature")
[Link]("Light Intensity (Lux)")
[Link]("Temperature (°C)")
[Link]()

# Histogram — Temperature Distribution


[Link]()
[Link](df['Temperature(°C)'], bins=15, color='orange', edgecolor='black')
[Link]("Temperature Distribution")
[Link]("Temperature (°C)")
[Link]("Frequency")
[Link]()

# Pie Chart — Motion Detection Events


motion_counts = df['MotionDetected'].value_counts()
[Link]()
[Link](motion_counts, labels=['No Motion', 'Motion Detected'],
autopct='%1.1f%%', startangle=90, colors=['#66b3ff','#ff9999'])
[Link]("Motion Detection Distribution")
[Link]()
# Correlation Heatmap — Relationships Between Variables
[Link](figsize=(6, 5))
corr = df[['Temperature(°C)', 'Humidity(%)', 'LightIntensity(Lux)', 'MotionDetected']].corr()
[Link](corr, cmap='coolwarm', interpolation='none')
[Link](label='Correlation')
[Link](range(len(corr)), [Link], rotation=45)
[Link](range(len(corr)), [Link])
[Link]("Correlation Heatmap of Sensor Variables")
plt.tight_layout()
[Link]()

You might also like