Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

matplotlib plot

import matplotlib.pyplot as plt
fig = plt.figure(1)	#identifies the figure 
plt.title("Y vs X", fontsize='16')	#title
plt.plot([1, 2, 3, 4], [6,2,8,4])	#plot the points
plt.xlabel("X",fontsize='13')	#adds a label in the x axis
plt.ylabel("Y",fontsize='13')	#adds a label in the y axis
plt.legend(('YvsX'),loc='best')	#creates a legend to identify the plot
plt.savefig('Y_X.png')	#saves the figure in the present directory
plt.grid()	#shows a grid under the plot
plt.show()
Comment

python plot

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.show()
Comment

how to plot in python

import matplotlib.pyplot as plt
import numpy as np

# Simple data to display in various forms
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)

fig, axarr = plt.subplots(2, 2)
fig.suptitle("This Main Title is Nicely Formatted", fontsize=16)

axarr[0, 0].plot(x, y)
axarr[0, 0].set_title('Axis [0,0] Subtitle')
axarr[0, 1].scatter(x, y)
axarr[0, 1].set_title('Axis [0,1] Subtitle')
axarr[1, 0].plot(x, y ** 2)
axarr[1, 0].set_title('Axis [1,0] Subtitle')
axarr[1, 1].scatter(x, y ** 2)
axarr[1, 1].set_title('Axis [1,1] Subtitle')

# Fine-tune figure;
# hide x ticks for top plots and y ticks for right plots

plt.setp([a.get_xticklabels() for a in axarr[0, :]], visible=False)
plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False)


# Tight layout often produces nice results
# but requires the title to be spaced accordingly

fig.tight_layout()
fig.subplots_adjust(top=0.88)

plt.show()


Comment

matplotlib.plot python

x = [1, 2, 3]
>>> y = np.array([[1, 2], [3, 4], [5, 6]])
>>> plot(x, y)
Comment

matplotlib.plot python

x = [1, 2, 3]
>>> y = np.array([[1, 2], [3, 4], [5, 6]])
>>> plot(x, y)
Comment

pyplot.plot

plot([x], y, [fmt], *, data=None, **kwargs)
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)
Comment

PREVIOUS NEXT
Code Example
Python :: python ascii code to string 
Python :: convert string to list of dictionaries 
Python :: python get list of files in directory 
Python :: pandas convert series of datetime to date 
Python :: python get volume free space 
Python :: how to fill a list in python 
Python :: how to check whole number in python 
Python :: python join with int 
Python :: python gui using css 
Python :: numpy how to slice individual columns 
Python :: search google images python 
Python :: module installed but not found python 
Python :: python replace accented characters code 
Python :: own labels for ticks matplotlib 
Python :: install flask on linux mint for python3 
Python :: print only numbers from string python 
Python :: dataframe nested json 
Python :: outliers removal pandas 
Python :: extend a class python 
Python :: df only take 2 columns 
Python :: how to print two lists side by side in python 
Python :: find the sum of all the multiples of 3 or 5 below 1000 python 
Python :: python is float 
Python :: true positive true negative manually 
Python :: python print boolean 
Python :: loop through list of tuples python 
Python :: dataframe drop rows by column value 
Python :: selection sort python 
Python :: draw bounding box on image python opencv 
Python :: python writelines 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =