How to use figure function(python, matplotlib). Draw multiple graphs



Python
library
pip

MeCab

Common
class

pickle

read/readline

numpy
asfarray

digitize

expit

linalg.solve

meshgrid

mgrid

ndmin

pad

poly1d

polyfit

prod

shape

matplotlib
figure

pcolormesh

scatter

pytorch
BCELoss, MSELoss

device

Embedding

TensorDataset, Dataloader

RNN, LSTM
scikit-learn
SVC

GaussianNB

scipy
interpolate
tkinter
postscript

image display

frame, grid

Crop Image

other
linear interpolation

Hysteresis switch

Square/Triangle wave

OpenAI gym
CartPole-v0

By purpose
1 of K Coding


Release date:2024/4/6         

In Japanese


■Figure function description

Draw multiple graphs.

■Concrete example
The following must be written in common for each specific example.

import matplotlib.pyplot as plt
import numpy as np # Defined to use the arange function

Example (1)
To display it in one window, use the following.

x=np.arange(10)
y1=x*2
y2=x*x

plt.figure()

plt.subplot(2,1,1) # Defined first in 2 rows and 1 column graph
plt.plot(x, y1)

plt.subplot(2,1,2) # Defined second in 2 rows and 1 column graph
plt.plot(x, y2)

plt.show()



Example (2)
To display in multiple windows, use the following.

x=np.arange(10)
y1=x*2
y2=x*x

plt.figure()
plt.plot(x, y1)

plt.figure()
plt.plot(x, y2)

plt.show()











List of related articles



Python
library
pip

MeCab

Common
class

pickle

read/readline

numpy
asfarray

digitize

expit

linalg.solve

meshgrid

mgrid

ndmin

pad

poly1d

polyfit

prod

shape

matplotlib
figure

pcolormesh

scatter

pytorch
BCELoss, MSELoss

device

Embedding

TensorDataset, Dataloader

RNN, LSTM
scikit-learn
SVC

GaussianNB

scipy
interpolate
tkinter
postscript

image display

frame, grid

Crop Image

other
linear interpolation

Hysteresis switch

Square/Triangle wave

OpenAI gym
CartPole-v0

By purpose
1 of K Coding