matplotlib Graph-related memorandum (minimum)

Localizing into Japanese

import matplotlib.pyplot as plt
import japanize_matplotlib

Save (set resolution)

plt.savefig("name.png ",format = 'png', dpi=300)

Create figure and axes at the same time

In the example below, ax has several rows x columns.

#Prepare a large area called figure and rows_graph×columns_Image to create graph drawing area
fig, ax = plt.subplots(rows_graph,columns_graph,figsize=(10,42))

#Access each ax element and plot.
ax[i,j].plot(x,y)

#If you want to draw multiple graphs, use the for statement (nested) to draw multiple graphs.
for j,day in enumerate(date_list):
    for i,item in enumerate(cal_items):
        ax[i,j].plot(x,y)

Title, axis, legend relationship

Note that it is a method of axes, not axis

ax.set_title('title')
ax.set_xlabel('x axis name')
ax.set_ylabel('y-axis name')
ax.set_xlim(min,max)
ax.set_ylim(min,max)
ax.legend(['A','B'])#When there are two series

https://matplotlib.org/1.5.1/faq/usage_faq.html#parts-of-a-figure fig_map.png

Recommended Posts

matplotlib Graph-related memorandum (minimum)
Matplotlib memorandum
Memorandum @ Python OR Seminar: matplotlib