graphing in python
# importing the required module
import matplotlib.pyplot as plt
# x axis values
x = [1,2,3]
# corresponding y axis values
y = [2,4,1]
# plotting the points
plt.plot(x, y)
# naming the x axis
plt.xlabel('x - axis')
# naming the y axis
plt.ylabel('y - axis')
# giving a title to my graph
plt.title('My first graph!')
# function to show the plot
plt.show()
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')
import matplotlib.pyplot as plt
# x axis values
x = [1,2,3,4,5,6]
# corresponding y axis values
y = [2,4,1,5,2,6]
# plotting the points
plt.plot(x, y, color='green', linestyle='dashed', linewidth = 3,
marker='o', markerfacecolor='blue', markersize=12)
# setting x and y axis range
plt.ylim(1,8)
plt.xlim(1,8)
# naming the x axis
plt.xlabel('x - axis')
# naming the y axis
plt.ylabel('y - axis')
# giving a title to my graph
plt.title('Some cool customizations!')
# function to show the plot
plt.show()