Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Visualizing HR Data with Matplotlib | Analyzing Employee Data
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for HR Specialists

bookVisualizing HR Data with Matplotlib

Data visualization is a vital tool for HR specialists because it transforms complex data into clear, actionable insights. In HR reporting, visualizations such as charts and graphs make it easier to spot trends, compare groups, and communicate findings to stakeholders who may not be familiar with raw data. By presenting employee information visually, you can quickly highlight key metrics like department sizes, gender distribution, and turnover rates. This approach not only streamlines decision-making but also helps ensure that important patterns in workforce data are not overlooked.

1234567891011
import matplotlib.pyplot as plt # Sample data: number of employees by department departments = ['Sales', 'Engineering', 'HR', 'Marketing'] employee_counts = [40, 55, 15, 20] plt.bar(departments, employee_counts, color='skyblue') plt.xlabel('Department') plt.ylabel('Number of Employees') plt.title('Employee Counts by Department') plt.show()
copy

In the code above, you start by importing the matplotlib.pyplot module, which provides functions for creating charts. Next, you define two lists: departments contains the department names, and employee_counts holds the number of employees in each department. The plt.bar function creates a bar chart using these lists, with the department names on the x-axis and the employee counts on the y-axis. You then add labels to the axes with plt.xlabel and plt.ylabel, and set a title for the chart using plt.title. Finally, calling plt.show() displays the chart in a new window.

12345678910
import matplotlib.pyplot as plt # Sample data: gender distribution genders = ['Male', 'Female', 'Non-binary'] counts = [60, 50, 5] plt.pie(counts, labels=genders, autopct='%1.1f%%', startangle=140, colors=['lightblue', 'pink', 'lightgreen']) plt.title('Gender Distribution Among Employees') plt.axis('equal') # Ensures pie is drawn as a circle plt.show()
copy

1. Why is data visualization useful in HR?

2. Which library is commonly used for plotting in Python?

3. Fill in the blank: To display a chart in matplotlib, use the _______ function.

question mark

Why is data visualization useful in HR?

Select all correct answers

question mark

Which library is commonly used for plotting in Python?

Select the correct answer

question-icon

Fill in the blank: To display a chart in matplotlib, use the _______ function.

plt.saveplt.plotplt.open

Click or drag`n`drop items and fill in the blanks

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 2

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Suggested prompts:

Can you explain how the pie chart code works?

What other types of HR data can be visualized using matplotlib?

How can I customize the colors or labels in these charts?

bookVisualizing HR Data with Matplotlib

Scorri per mostrare il menu

Data visualization is a vital tool for HR specialists because it transforms complex data into clear, actionable insights. In HR reporting, visualizations such as charts and graphs make it easier to spot trends, compare groups, and communicate findings to stakeholders who may not be familiar with raw data. By presenting employee information visually, you can quickly highlight key metrics like department sizes, gender distribution, and turnover rates. This approach not only streamlines decision-making but also helps ensure that important patterns in workforce data are not overlooked.

1234567891011
import matplotlib.pyplot as plt # Sample data: number of employees by department departments = ['Sales', 'Engineering', 'HR', 'Marketing'] employee_counts = [40, 55, 15, 20] plt.bar(departments, employee_counts, color='skyblue') plt.xlabel('Department') plt.ylabel('Number of Employees') plt.title('Employee Counts by Department') plt.show()
copy

In the code above, you start by importing the matplotlib.pyplot module, which provides functions for creating charts. Next, you define two lists: departments contains the department names, and employee_counts holds the number of employees in each department. The plt.bar function creates a bar chart using these lists, with the department names on the x-axis and the employee counts on the y-axis. You then add labels to the axes with plt.xlabel and plt.ylabel, and set a title for the chart using plt.title. Finally, calling plt.show() displays the chart in a new window.

12345678910
import matplotlib.pyplot as plt # Sample data: gender distribution genders = ['Male', 'Female', 'Non-binary'] counts = [60, 50, 5] plt.pie(counts, labels=genders, autopct='%1.1f%%', startangle=140, colors=['lightblue', 'pink', 'lightgreen']) plt.title('Gender Distribution Among Employees') plt.axis('equal') # Ensures pie is drawn as a circle plt.show()
copy

1. Why is data visualization useful in HR?

2. Which library is commonly used for plotting in Python?

3. Fill in the blank: To display a chart in matplotlib, use the _______ function.

question mark

Why is data visualization useful in HR?

Select all correct answers

question mark

Which library is commonly used for plotting in Python?

Select the correct answer

question-icon

Fill in the blank: To display a chart in matplotlib, use the _______ function.

plt.saveplt.plotplt.open

Click or drag`n`drop items and fill in the blanks

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 2
some-alt