# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3.9.9 64-bit
#     language: python
#     name: python3
# ---

# ## What is Matplotlib?
# Matplotlib is a low level graph plotting library in python that serves as a visualization utility.
#
# Matplotlib was created by <NAME>.
#
# Matplotlib is open source and we can use it freely.
#
# Matplotlib is mostly written in python, a few segments are written in C, Objective-C and Javascript for Platform compatibility.
#
#

# +
import matplotlib

print(matplotlib.__version__)

# -

import matplotlib.pyplot as plt
import numpy as np

# +
xpoints = np.array([0,6])
ypoints = np.array([0, 250])

plt.plot(xpoints, ypoints)
plt.show()

# +
#Plotting Without Line
#To plot only the markers, you can use shortcut string notation parameter 'o', which means 'rings'.

xpoints = np.array([1, 8])
ypoints = np.array([3, 10])

plt.plot(xpoints, ypoints, 'o')
plt.show()


# +
# Multiple Points
xpoints = np.array([1, 2, 6, 8])
ypoints = np.array([3, 8, 1, 10])

plt.plot(xpoints, ypoints)
plt.show()


# +
# Markers

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, marker='o')
plt.show()

plt.plot(ypoints, marker='*')
plt.show()

plt.plot(ypoints, 'o:r', ms=10, mec='#4CAF50', mfc='#4CAF50')
plt.show()


# +
#Matplotlib Line

ypoints = np.array([3, 8, 1, 10])

plt.plot(ypoints, linestyle='dotted')
plt.show()

plt.plot(ypoints, linestyle='dashed')
plt.show()


# +
# Multilines

y1 = np.array([3, 8, 1, 10])
y2 = np.array([6, 2, 7, 11])

plt.plot(y1)
plt.plot(y2)

plt.show()


# +
# Mathplotlib Labels and Title
x = np.array([80, 85, 90, 95, 100, 105, 110, 115, 120, 125])
y = np.array([240, 250, 260, 270, 280, 290, 300, 310, 320, 330])

plt.plot(x, y)

plt.title("Sports Watch Data", loc="left")
plt.xlabel("Average Pulse")
plt.ylabel("Calorie Burnage")

plt.grid()

plt.show()

# -

# The subplots() Function
# The subplots() function takes three arguments that describes the layout of the figure.
#
# The layout is organized in rows and columns, which are represented by the first and second argument.
#
# The third argument represents the index of the current plot.
#
# ```python
# plt.subplot(1, 2, 1)
# #the figure has 1 row, 2 columns, and this plot is the first plot.
# ```

# +
# Subplots

#plot 1:
x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])

plt.subplot(1, 2, 1)
plt.plot(x, y)

#plot 2:
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])

plt.subplot(1, 2, 2)
plt.plot(x, y)

plt.show()


# +

#plot 1:
x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])

plt.subplot(2, 1, 1)
plt.plot(x, y)

#plot 2:
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])

plt.subplot(2, 1, 2)
plt.plot(x, y)

plt.suptitle("سلام")
plt.show()


StarcoderdataJupyterScriptsDedupFiltered