You are on page 1of 5

PROGRAM - 10

#horizontal graph
import numpy as np
import matplotlib.pyplot as mp
language=['python','c','c++','java','vb']
usage=[10,4,10,12,8]
y=np.arange(len(language))
mp.barh(y,usage,align='center',color=['b','r','k','g','y'])
"""mp.barh(language,usage,color=['b','r','k','g','y'])"""
mp.yticks(y,language)
mp.xlabel("Usage")
mp.ylabel("Programming Language")
mp.title("Programming Language Usage")
mp.show()

PROGRAM-11
#to plot two list elements
import matplotlib.pyplot as mp
x=[2,4,6,8,10]
y=[12,14,16,18,20]
a=[1,3,5,7,9]
b=[11,13,15,8,18]
mp.bar(x,y,label='bar1')
mp.bar(a,b,label='bar2')
mp.xlim(0,12)
mp.ylim(0,21)
mp.xlabel("X-axis")
mp.ylabel("Y-axis")
mp.title("Bar GRaph with multiline")
mp.legend()
mp.show()

PROGRAM12
#scatter chart
import matplotlib.pyplot as p
import numpy as n
a=range(1,11)
b=n.log(a)
c=n.sqrt(a)
p.figure(figsize=(10,8))
p.scatter(a,b,marker='+',label="Log Values")
p.xlabel("Values")
p.ylabel("Logrithm values")
p.scatter(a,c,marker='*',c='k',label="Square root values")
p.xlabel("Values")
p.ylabel("square root values")
p.legend()
p.show()

PROGRAM 13
#scatter chart
"""write a program to plot a scatter graph taking a random
distribution in
X and Y both with shape as (100,) having randomly generated
integers and plotted
against each other."""
import matplotlib.pyplot as p
import numpy as n
a=n.random.randint(1,100,size=(100,))
print(a)

b=n.random.randint(1,100,size=(100,))
p.scatter(a,b,c='r')
p.xlabel(" X Values")
p.ylabel("Y Values")
p.show()

PROGRAM 14
#scatter chart
"""write a program to plot a scatter graph taking a random
distribution in
X and Y both with shape as (250,) having randomly generated
integers
and plotted
against each other with varying size and varying colors."""
import matplotlib.pyplot as p
import numpy as n
a=n.random.randint(1,100,size=(250,))
print(a)

b=n.random.randint(1,100,size=(250,))
print(b)
size=range(1,251)
colr=[]
for i in range(250):
x=n.random.choice(['r','b','c','m','g','k','y'])
colr.append(x)
p.scatter(a,b,c=colr,s=size)
p.xlabel(" X Values")
p.ylabel("Y Values")
p.show()

PROGRAM 15
#scatter chart
"""write a program to plot a scatter graph taking three random
distribution in
X,Y and Z with shape as (250,) having randomly generated
integers and plotted
against each other with varying sizes and varying colors."""
import matplotlib.pyplot as p
import numpy as n
a=n.random.randint(1,100,size=(250,))
b=n.random.randint(1,100,size=(250,))
c=n.random.randint(1,100,size=(250,))
p.scatter(a,b,c='r',s=4)
p.scatter(a,c,c='k',s=15)
p.xlabel(" X Values")
p.ylabel("Y and Z Values")
p.show()

PROGRAM 16
#scatter chart
import numpy as n
import matplotlib.pyplot as mp
a=n.linspace(-1,1,5)
print(a)
b=n.exp(a)
print(b)
color=['r','b','m','g','k']
size=[20,60,35,100,45]
mp.scatter(a,b,c=color,s=size)
mp.show()

You might also like