Answers for "matplotlib plotting python"

16

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()
Posted by: Guest on January-05-2021
5

plot using matplotlib

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
Posted by: Guest on February-21-2020
0

how do a plot on matplotlib python

import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(data)
#this is not nessisary but makes your plot more readable
plt.ylabel('y axis means ...')
plt.xlabel('x axis means ...')
Posted by: Guest on June-29-2020
0

matplotlib plot

>>> rng = np.arange(50)
>>> rnd = np.random.randint(0, 10, size=(3, rng.size))
>>> yrs = 1950 + rng

>>> fig, ax = plt.subplots(figsize=(5, 3))
>>> ax.stackplot(yrs, rng + rnd, labels=['Eastasia', 'Eurasia', 'Oceania'])
>>> ax.set_title('Combined debt growth over time')
>>> ax.legend(loc='upper left')
>>> ax.set_ylabel('Total debt')
>>> ax.set_xlim(xmin=yrs[0], xmax=yrs[-1])
>>> fig.tight_layout()
Posted by: Guest on January-27-2021
0

matplotlib plotting python

import numpy as np
import matplotlib.pyplot as plt

fig, axs = plt.subplots(nrows=2, ncols=2)

axs[0, 0].plot(ax1,color='b', alpha=0.5)
axs[0, 1].plot(ax2,color='g', alpha=0.5 )
axs[1, 0].plot(ax3,color='y', alpha=0.5)
axs[1, 1].plot(ax4,color='r', alpha=0.5 )

fig.tight_layout()
plt.show()

########################################
import numpy as np
import matplotlib.pyplot as plt

fig, axs = plt.subplots(nrows=3, ncols=2, figsize=(7, 7))

# plot time signal:
axs[0, 0].set_title("Signal")
axs[0, 0].hist(ax1, color='C0')
axs[0, 0].set_xlabel("Time")
axs[0, 0].set_ylabel("Amplitude")


# plot different spectrum types:
axs[1, 0].set_title("Magnitude Spectrum")
axs[1, 0].hist(ax2, color='C1')

axs[1, 1].set_title("Log. Magnitude Spectrum")
axs[1, 1].hist(ax3, color='C1')

axs[2, 0].set_title("Phase Spectrum ")
axs[2, 0].hist(ax4, color='C2')

axs[2, 1].set_title("Angle Spectrum")
axs[2, 1].hist(ax5, color='C2')

axs[0, 1].remove()  # don't display empty ax

fig.tight_layout()
plt.show()
Posted by: Guest on November-21-2021

Code answers related to "matplotlib plotting python"

Python Answers by Framework

Browse Popular Code Answers by Language