Background: We needed a program to adjust the graph when dealing with small and large data at the same time or when small changes are not so important.
For the time being, it is only necessary to be able to set the range of the axes of the graph.
Operating environment: Linux (Ubuntu 16.04.2 LTS), python3.6.2, matplotlib (2.0.2)
Purpose: Specify the axis range of the graph Take the average value of the array with numpy and set the upper and lower digits of it to the maximum and minimum of the graph.
Also, when entering a value directly to specify the range of the graph set_ylim([min,max]) To use.
(Source code)
#Array x,x in the graph to y respectively,Contains y-worthy data.*/
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
#(abridgement)
#Calculate the average value of y#
ave=np.average(y)
ax=plt.subplot()
ax.plot(x,y,linewidth=0.3)
ax.grid(which="both")
ax.set_xlabel("x")
ax.set_ylabel("y")
#Set of ranges
ax.set_ylim([ave*0.1,ave*10])
plt.show()
Recommended Posts