kinkoh
0
Q:

matplotlib

pip install matplotlib
11
pip install matplotlib==3.0.3
3
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]

plt.figure(figsize=(9, 3))

plt.subplot(131)
plt.bar(names, values)
plt.subplot(132)
plt.scatter(names, values)
plt.subplot(133)
plt.plot(names, values)
plt.suptitle('Categorical Plotting')
plt.show()
2
# To plot pretty figures
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rc('axes', labelsize=14)
mpl.rc('xtick', labelsize=12)
mpl.rc('ytick', labelsize=12)
1
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
6
from matplotlib import pyplot as plt

# Median Developer Salaries by Age
dev_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]

dev_y = [38496, 42000, 46752, 49320, 53200,
         56000, 62316, 64928, 67317, 68748, 73752]

plt.plot(dev_x, dev_y)
plt.xlabel('Ages')
plt.ylabel('Median Salary (USD)')
plt.title('Median Salary (USD) by Age')
plt.show()

#Basic line graph using python module matplotlib
1
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax1 = fig.add_axes((0.1,0.4,0.5,0.5))

ax1.set_title('Title of Plot')
ax1.set_xlabel('X')
ax1.set_ylabel('Y')

ax1.plot(X,Y,c='black',linestyle='--',linewidth=0.5)
ax1.scatter(X,Y,c='red',s=0.5)
ax1.legend(['Line','Scatter'])

ax1.xaxis.set_ticks([0.0,0.1,0.2,0.3])
ax1.yaxis.set_ticks([0.0,0.1,0.2,0.3])

ax1.grid(which='major')
ax1.tick_params(direction='in')

txt = 'Write something on the graph page\
		\n over one or more lines.'

fig.text(0.5,0.05,txt,ha='center')

fig.savefig('Figure.pdf')
1
# importing matplotlib module  
from matplotlib import pyplot as plt 
  
# x-axis values 
x = [5, 2, 9, 4, 7] 
  
# Y-axis values 
y = [10, 5, 8, 4, 2] 
  
# Function to plot scatter 
plt.scatter(x, y) 
  
# function to show the plot 
plt.show()
7
import matplotlib
0

New to Communities?

Join the community