0% found this document useful (0 votes)
43 views1 page

Test - Generate - Plot - With - Style2

This document regenerates a bar plot defined in a previous example using the 'seaborn-colorblind' style in matplotlib. It imports necessary libraries, applies the style context, and generates a bar plot with 4 sets of bars for sepal length, sepal width, petal length, and petal width of 3 iris species. Labels, titles, axes limits, and a legend are added to the plot.

Uploaded by

pavan developer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views1 page

Test - Generate - Plot - With - Style2

This document regenerates a bar plot defined in a previous example using the 'seaborn-colorblind' style in matplotlib. It imports necessary libraries, applies the style context, and generates a bar plot with 4 sets of bars for sepal length, sepal width, petal length, and petal width of 3 iris species. Labels, titles, axes limits, and a legend are added to the plot.

Uploaded by

pavan developer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

2.

test_generate_plot_with_style2
Regenerate the barplot defined in 'generate_plot_with_style1' using 'seaborn-colorblind' style. Use 'with'
for applying the style.

In [13]:
import matplotlib.pyplot as plt
import numpy as np
with plt.style.context('seaborn-colorblind'):
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(111)
sepal_len = [5.01, 5.94, 6.59]
sepal_wd = [3.42, 2.77, 2.97]
petal_len = [1.46, 4.26, 5.55]
petal_wd = [0.24, 1.33, 2.03]
species = ['setosa', 'versicolor', 'viriginica']
species_index1 = [0.7, 1.7, 2.7]
species_index2 = [0.9, 1.9, 2.9]
species_index3 = [1.1, 2.1, 3.1]
species_index4 = [1.3, 2.3, 3.3]

ax.bar(species_index1,sepal_len,edgecolor='black',width=0.2,label='Sepal
Length')
ax.bar(species_index2,sepal_wd,edgecolor='black',width=0.2,label='Sepal
Width')

ax.bar(species_index3,petal_len,edgecolor='black',width=0.2,label='Petal
Length')
ax.bar(species_index4,petal_wd,edgecolor='black',width=0.2,label='Petal
Width')
ax.set(title="Mean Measurements of Iris
Species",xlabel="Species",ylabel="Iris Measurements (cm)"
,xlim=(0.5,3.7),ylim=(0,10),xticks=[1.1,2.1,3.1],xticklabels=spe
cies)
ax.legend()

You might also like