Matplotlib
Matplotlib
Matplotlib
↳ 3 cells hidden
Importing library
[ ] ↳ 2 cells hidden
[ ] ↳ 6 cells hidden
import numpy as np
plt.style.use("fivethirtyeight")
import matplotlib.pyplot as plt
plt.style.use("fivethirtyeight")
x_indexes = np.arange(len(ages_x))
width = 0.25
https://colab.research.google.com/drive/1-e6frQL-0mSS9pEkO968J_tU35DC6Zfo Page 1 of 7
Matplotlib.ipynb - Colab 26/05/24, 4:34 PM
plt.xticks(ticks=x_indexes, labels=ages_x)
plt.legend()
plt.tight_layout()
plt.show()
https://colab.research.google.com/drive/1-e6frQL-0mSS9pEkO968J_tU35DC6Zfo Page 2 of 7
Matplotlib.ipynb - Colab 26/05/24, 4:34 PM
The plt.xticks() function in Matplotlib is used to customize the tick locations and labels on
the x-axis of a plot. Here's an explanation of the parameters:
ticks: This parameter speciMes the locations on the x-axis where you want to place the ticks.
It takes a list of values indicating the positions of the ticks. In your example, x_indexes likely
contains the positions where you want to place ticks on the x-axis.
labels: This parameter is used to provide custom labels for the ticks. It takes a list of labels
corresponding to the tick positions speciMed in the ticks parameter. In your example, ages_x
likely contains the labels that you want to display at each tick position.
import csv
language_counter = Counter()
languages = []
popularity = []
# print(languages)
# print(popularity)
languages.reverse()
popularity.reverse()
# plt.bar(languages, popularity)
https://colab.research.google.com/drive/1-e6frQL-0mSS9pEkO968J_tU35DC6Zfo Page 3 of 7
Matplotlib.ipynb - Colab 26/05/24, 4:34 PM
plt.legend()
plt.tight_layout()
plt.show()
import pandas as pd
data = pd.read_csv("/content/matplotlib_2.csv")
ids = data['Responder_id']
lang_responses = data['LanguagesWorkedWith']
languages = []
popularity = []
https://colab.research.google.com/drive/1-e6frQL-0mSS9pEkO968J_tU35DC6Zfo Page 4 of 7
Matplotlib.ipynb - Colab 26/05/24, 4:34 PM
# print(languages)
# print(popularity)
languages.reverse()
popularity.reverse()
# plt.bar(languages, popularity)
plt.legend()
plt.tight_layout()
plt.show()
https://colab.research.google.com/drive/1-e6frQL-0mSS9pEkO968J_tU35DC6Zfo Page 5 of 7
Matplotlib.ipynb - Colab 26/05/24, 4:34 PM
https://colab.research.google.com/drive/1-e6frQL-0mSS9pEkO968J_tU35DC6Zfo Page 6 of 7
Matplotlib.ipynb - Colab 26/05/24, 4:34 PM
https://colab.research.google.com/drive/1-e6frQL-0mSS9pEkO968J_tU35DC6Zfo Page 7 of 7